<parent>
<groupId>org.onap.holmes.engine-management</groupId>
<artifactId>holmes-engine-parent</artifactId>
- <version>1.3.7-SNAPSHOT</version>
+ <version>1.3.8-SNAPSHOT</version>
</parent>
<artifactId>holmes-engine-d-standalone</artifactId>
</executions>
<configuration>
<outputDirectory>${linux64outputdir}/lib</outputDirectory>
+ <overWriteIfNewer>true</overWriteIfNewer>
<includeScope>runtime</includeScope>
</configuration>
</plugin>
</resource>
<resource>
<directory>../engine-d/src/main/resources</directory>
+ <excludes>
+ <exclude>logback-spring.xml</exclude>
+ </excludes>
<filtering>false</filtering>
</resource>
</resources>
echo "No database is name is specified. Use the default value \"$DB_NAME\"."
fi
+export DB_PORT=5432
+if [ ! -z ${URL_JDBC} ] && [ `expr index $URL_JDBC :` != 0 ]; then
+ export DB_PORT="${URL_JDBC##*:}"
+fi
+echo DB_PORT=$DB_PORT
+
# if deployed using helm, use the helm-generated configuration file.
if [ -d /opt/hemconfig ]; then
- cp /opt/hemconfig/engine-d.yml "$main_path/conf/engine-d.yml"
+ cp /opt/hemconfig/application.yaml "$main_path/conf/application.yaml"
else
- sed -i "s|url:.*|url: jdbc:postgresql://$URL_JDBC/$DB_NAME|" "$main_path/conf/engine-d.yml"
- sed -i "s|user:.*|user: $JDBC_USERNAME|" "$main_path/conf/engine-d.yml"
- sed -i "s|password:.*|password: $JDBC_PASSWORD|" "$main_path/conf/engine-d.yml"
+ sed -i "s|url:.*|url: jdbc:postgresql://$URL_JDBC:$DB_PORT/$DB_NAME|" "$main_path/conf/application.yaml"
+ sed -i "s|username:.*|username: $JDBC_USERNAME|" "$main_path/conf/application.yaml"
+ sed -i "s|password:.*|password: $JDBC_PASSWORD|" "$main_path/conf/application.yaml"
fi
export SERVICE_IP=`hostname -i | awk '{print $1}'`
export HOSTNAME=${SERVICE_IP}:9102
fi
-export DB_PORT=5432
-if [ ! -z ${URL_JDBC} ] && [ `expr index $URL_JDBC :` != 0 ]; then
- export DB_PORT="${URL_JDBC##*:}"
-fi
-echo DB_PORT=$DB_PORT
-
if [ -z ${ENABLE_ENCRYPT} ]; then
export ENABLE_ENCRYPT=true
fi
echo ENABLE_ENCRYPT=$ENABLE_ENCRYPT
-KEY_PATH="/opt/onap/conf/holmes.keystore"
+KEY_PATH="$main_path/conf/holmes.keystore"
KEY_PASSWORD="holmes"
if [ -f "/opt/app/osaaf/local/org.onap.holmes-engine-mgmt.p12" ]; then
echo "KEY_PASS=$KEY_PASSWORD"
#HTTPS Configurations
-sed -i "s|keyStorePath:.*|keyStorePath: $KEY_PATH|" "$main_path/conf/engine-d.yml"
-sed -i "s|keyStorePassword:.*|keyStorePassword: $KEY_PASSWORD|" "$main_path/conf/engine-d.yml"
+sed -i "s|key-store:.*|key-store: $KEY_PATH|" "$main_path/conf/application.yaml"
+sed -i "s|key-store-password:.*|key-store-password: $KEY_PASSWORD|" "$main_path/conf/application.yaml"
if [ "${ENABLE_ENCRYPT}"x = "true"x ]; then
sed -i "s|type:\s*https\?$|type: https|" "$main_path/conf/engine-d.yml"
sed -i "s|#\?validatePeers|#validatePeers|" "$main_path/conf/engine-d.yml"
fi
-cat "$main_path/conf/engine-d.yml"
+cat "$main_path/conf/application.yaml"
${RUNHOME}/initDB.sh "$JDBC_USERNAME" "$JDBC_PASSWORD" "$DB_NAME" "$DB_PORT" "${URL_JDBC%:*}"
-"$JAVA" $JAVA_OPTS -classpath "$class_path" org.onap.holmes.engine.EngineDActiveApp server "$main_path/conf/engine-d.yml"
+JAR=`ls -lt $main_path/lib | grep -e "holmes-engine-.*jar$" | awk '{print $9}'`
+"$JAVA" $JAVA_OPTS -jar "$main_path/lib/$JAR" -classpath "$class_path" --spring.config.location="$main_path/conf/application.yaml"
--- /dev/null
+server:
+ port: 9102
+ servlet:
+ context-path: /api/holmes-engine-mgmt/v1
+ ssl:
+ key-store: /opt/onap/conf/holmes.keystore
+ key-store-password: holmes
+ #PKCS12
+ key-store-type: JKS
+
+logging:
+ config: classpath:logback-spring.xml
+
+spring:
+ application:
+ name: Holmes Engine Management
+ datasource:
+ dirver-class-name: org.postgresql.Driver
+ url: jdbc:postgresql://localhost:5432/holmes
+ username: holmes
+ password: holmespwd
+ mvc:
+ throw-exception-if-no-handler-found: true
\ No newline at end of file
<parent>
<groupId>org.onap.holmes.engine-management</groupId>
<artifactId>holmes-engine-parent</artifactId>
- <version>1.3.7-SNAPSHOT</version>
+ <version>1.3.8-SNAPSHOT</version>
</parent>
<artifactId>holmes-engine-d</artifactId>
<name>holmes-engine-d-service</name>
<packaging>jar</packaging>
+ <properties>
+ <main-class>org.onap.holmes.engine.EngineDActiveApp</main-class>
+ </properties>
+
<build>
<resources>
<resource>
</resource>
<resource>
<directory>src/main/resources</directory>
+ <excludes>
+ <exclude>swagger.json</exclude>
+ </excludes>
</resource>
</resources>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${springboot.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <mainClass>${main-class}</mainClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ <configuration>
+ <source>8</source>
+ <target>8</target>
+ <release>11</release>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>${jacoco.version}</version>
+ <executions>
+ <execution>
+ <id>prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>report</id>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ <configuration>
+ <dataFile>${project.build.directory}/code-coverage/jacoco.exec</dataFile>
+ <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
<profiles>
<version>1.5.0</version>
</dependency>
</dependencies>
-
<build>
<plugins>
<plugin>
*/
package org.onap.holmes.dsa.dmaappolling;
+import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.api.stat.VesAlarm;
import org.onap.holmes.common.api.stat.AlarmAdditionalField;
-import com.google.gson.Gson;
+import org.onap.holmes.common.api.stat.VesAlarm;
+import org.springframework.stereotype.Component;
-import java.util.Map;
-import java.util.TimeZone;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
import static org.onap.holmes.common.utils.GsonUtil.*;
-@Service
+@Component
public class DMaaPResponseUtil {
public VesAlarm convertJsonToVesAlarm(String responseJson) {
/*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.onap.holmes.common.api.stat.VesAlarm;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.JerseyClient;
+import org.onap.holmes.common.utils.SpringContextUtil;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Slf4j
public class Subscriber {
- private DMaaPResponseUtil dMaaPResponseUtil = ServiceLocatorHolder.getLocator()
- .getService(DMaaPResponseUtil.class);
+ private DMaaPResponseUtil dMaaPResponseUtil = SpringContextUtil.getBean(DMaaPResponseUtil.class);
/**
* The number of milliseconds to wait for messages if none are immediately available. This
/**
- * Copyright 2017-2021 ZTE Corporation.
+ * Copyright 2017-2022 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.
*/
package org.onap.holmes.engine;
-import io.dropwizard.setup.Environment;
import lombok.extern.slf4j.Slf4j;
import org.onap.holmes.common.ConfigFileScanner;
-import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
-import org.onap.holmes.common.utils.transactionid.TransactionIdFilter;
import org.onap.holmes.engine.dcae.ConfigFileScanningTask;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.context.annotation.ComponentScan;
-import javax.servlet.DispatcherType;
-import java.util.EnumSet;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@Slf4j
-public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> {
-
- public static void main(String[] args) throws Exception {
- new EngineDActiveApp().run(args);
+@SpringBootApplication
+@ServletComponentScan
+@ComponentScan(basePackages = {"org.onap.holmes"})
+public class EngineDActiveApp implements ApplicationRunner {
+ public static void main(String[] args) {
+ SpringApplication.run(EngineDActiveApp.class, args);
}
@Override
- public void run(EngineDAppConfig configuration, Environment environment) throws Exception {
- super.run(configuration, environment);
-
-
+ public void run(ApplicationArguments args) {
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(
new ConfigFileScanningTask(new ConfigFileScanner()), 60L,
ConfigFileScanningTask.POLLING_PERIOD, TimeUnit.SECONDS);
-
- environment.servlets().addFilter("logFilter", new TransactionIdFilter()).addMappingForUrlPatterns(EnumSet
- .allOf(DispatcherType.class), true, "/*");
-
Initializer.setReadyForMsbReg(true);
}
}
+++ /dev/null
-/**
- * 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.engine;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import io.dropwizard.Configuration;
-import io.dropwizard.db.DataSourceFactory;
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-import org.jvnet.hk2.annotations.Service;
-
-@Service
-public class EngineDAppConfig extends Configuration {
-
- private String apidescription = "Holmes rule management rest API";
-
- @Valid
- @NotNull
- private DataSourceFactory database = new DataSourceFactory();
-
- @JsonProperty("database")
- public DataSourceFactory getDataSourceFactory() {
- return database;
- }
-
- @JsonProperty("database")
- public void setDataSourceFactory(DataSourceFactory dataSourceFactory) {
- this.database = dataSourceFactory;
- }
-
- public String getApidescription() {
- return apidescription;
- }
-
- public void setApidescription(String apidescription) {
- this.apidescription = apidescription;
- }
-}
/**
- * Copyright 2017-2018 ZTE Corporation.
+ * Copyright 2017-2022 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.
package org.onap.holmes.engine;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.CommonUtils;
import org.onap.holmes.common.utils.MsbRegister;
import org.onap.msb.sdk.discovery.entity.Node;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static org.onap.holmes.common.config.MicroServiceConfig.POD_IP;
import static org.onap.holmes.common.config.MicroServiceConfig.getMicroServiceIpAndPort;
import static org.onap.holmes.common.utils.CommonUtils.getEnv;
import static org.onap.holmes.common.utils.CommonUtils.isIpAddress;
-@Service
-public class Initializer {
+@Component
+public class Initializer implements ApplicationRunner {
private static final Logger logger = LoggerFactory.getLogger(Initializer.class);
private volatile static boolean readyForMsbReg = false;
private MsbRegister msbRegister;
- @Inject
+ @Autowired
public Initializer(MsbRegister msbRegister) {
this.msbRegister = msbRegister;
}
- @PostConstruct
- private void init() {
+ @Override
+ public void run(ApplicationArguments args) {
Executors.newSingleThreadExecutor().execute(() -> {
waitUntilReady();
try {
msinfo.setEnable_ssl(CommonUtils.isHttpsEnabled());
Set<Node> nodes = new HashSet<>();
Node node = new Node();
- node.setIp(isIpAddress(serviceIpAndPort[0]) ? serviceIpAndPort[0] : getEnv(POD_IP));
+ node.setIp(isIpAddress(serviceIpAndPort[0]) ? serviceIpAndPort[0] : getEnv("HOLMES_ENGINE_MGMT_SERVICE_HOST"));
node.setPort("9102");
/* Following codes will cause an unregistration from MSB (due to MSB malfunction), comment them for now
String msbAddrTemplate = (CommonUtils.isHttpsEnabled() ? "https" : "http")
-/**\r
- * Copyright 2017 ZTE Corporation.\r
- * <p>\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * <p>\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * <p>\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onap.holmes.engine.db;\r
-\r
-import org.onap.holmes.common.api.entity.AlarmInfo;\r
-import org.onap.holmes.common.exception.AlarmInfoException;\r
-import org.onap.holmes.common.utils.AlarmInfoMapper;\r
-import org.skife.jdbi.v2.sqlobject.*;\r
-import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;\r
-\r
-import java.util.List;\r
-\r
-@RegisterMapper(AlarmInfoMapper.class)\r
-public abstract class AlarmInfoDao {\r
-\r
- @GetGeneratedKeys\r
- @SqlUpdate("INSERT INTO ALARM_INFO (EVENTID,EVENTNAME,STARTEPOCHMICROSEC,SOURCEID,SOURCENAME,SEQUENCE,ALARMISCLEARED,ROOTFLAG,LASTEPOCHMICROSEC) VALUES (:eventId,:eventName,:startEpochMicroSec,:sourceId,:sourceName,:sequence,:alarmIsCleared,:rootFlag,:lastEpochMicroSec)")\r
- protected abstract String addAlarm(@BindBean AlarmInfo alarmInfo);\r
-\r
- @SqlQuery("SELECT * FROM ALARM_INFO")\r
- protected abstract List<AlarmInfo> queryAlarm();\r
-\r
- @SqlUpdate("DELETE FROM ALARM_INFO WHERE EVENTNAME=:eventName AND SOURCEID=:sourceId AND SOURCENAME=:sourceName")\r
- protected abstract int deleteAlarmByAlarmIsCleared(@Bind("eventName") String eventName,\r
- @Bind("sourceId") String sourceId,\r
- @Bind("sourceName") String sourceName);\r
-\r
- public AlarmInfo saveAlarm(AlarmInfo alarmInfo) throws AlarmInfoException {\r
- try {\r
- addAlarm(alarmInfo);\r
- return alarmInfo;\r
- } catch (Exception e) {\r
- throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);\r
- }\r
- }\r
-\r
- public List<AlarmInfo> queryAllAlarm() throws AlarmInfoException {\r
- try {\r
- return queryAlarm();\r
- } catch (Exception e) {\r
- throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);\r
- }\r
- }\r
-\r
- public void deleteAlarm(AlarmInfo alarmInfo) {\r
- if (alarmInfo.getAlarmIsCleared() != 1) {\r
- return;\r
- }\r
-\r
- String sourceId = alarmInfo.getSourceId();\r
- String sourceName = alarmInfo.getSourceName();\r
- String eventName = alarmInfo.getEventName();\r
- eventName = eventName.substring(0, eventName.lastIndexOf("Cleared"));\r
-\r
- deleteAlarmByAlarmIsCleared(eventName, sourceId, sourceName);\r
- }\r
-}\r
+/**
+ * Copyright 2021-2022 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.engine.db;
+
+import org.onap.holmes.common.api.entity.AlarmInfo;
+import org.onap.holmes.common.exception.AlarmInfoException;
+import org.onap.holmes.engine.db.jdbi.AlarmInfoDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+
+public class AlarmInfoDaoService {
+
+ @Autowired
+ private AlarmInfoDao alarmInfoDao;
+
+ public AlarmInfo saveAlarm(AlarmInfo alarmInfo) throws AlarmInfoException {
+ try {
+ alarmInfoDao.addAlarm(alarmInfo);
+ return alarmInfo;
+ } catch (Exception e) {
+ throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);
+ }
+ }
+
+ public List<AlarmInfo> queryAllAlarm() throws AlarmInfoException {
+ try {
+ return alarmInfoDao.queryAlarm();
+ } catch (Exception e) {
+ throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);
+ }
+ }
+
+ public void deleteAlarm(AlarmInfo alarmInfo) {
+ if (alarmInfo.getAlarmIsCleared() != 1) {
+ return;
+ }
+
+ String sourceId = alarmInfo.getSourceId();
+ String sourceName = alarmInfo.getSourceName();
+ String eventName = alarmInfo.getEventName();
+ eventName = eventName.substring(0, eventName.lastIndexOf("Cleared"));
+
+ alarmInfoDao.deleteAlarmByAlarmIsCleared(eventName, sourceId, sourceName);
+ }
+}
--- /dev/null
+/**
+ * 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.engine.db;
+
+import org.onap.holmes.common.api.entity.CorrelationRule;
+import org.onap.holmes.engine.db.jdbi.CorrelationRuleDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class CorrelationRuleDaoService {
+
+ @Autowired
+ private CorrelationRuleDao correlationRuleDao;
+
+ public List<CorrelationRule> queryRuleByRuleEnable(int enable) {
+ return correlationRuleDao.queryRuleByEnable(enable);
+ }
+}
--- /dev/null
+/**
+ * Copyright 2022 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.engine.db;
+
+import org.jdbi.v3.core.Jdbi;
+import org.onap.holmes.engine.db.jdbi.AlarmInfoDao;
+import org.onap.holmes.engine.db.jdbi.CorrelationRuleDao;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class DaoProvider {
+
+ @Bean
+ public AlarmInfoDao alarmInfoDao(Jdbi jdbi) {
+ return jdbi.onDemand(AlarmInfoDao.class);
+ }
+
+ @Bean
+ public CorrelationRuleDao correlationRuleDao(Jdbi jdbi) {
+ return jdbi.onDemand(CorrelationRuleDao.class);
+ }
+}
--- /dev/null
+/**\r
+ * Copyright 2017-2022 ZTE Corporation.\r
+ * <p>\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.onap.holmes.engine.db.jdbi;\r
+\r
+import org.jdbi.v3.sqlobject.config.RegisterRowMapper;\r
+import org.jdbi.v3.sqlobject.customizer.Bind;\r
+import org.jdbi.v3.sqlobject.customizer.BindBean;\r
+import org.jdbi.v3.sqlobject.statement.GetGeneratedKeys;\r
+import org.jdbi.v3.sqlobject.statement.SqlQuery;\r
+import org.jdbi.v3.sqlobject.statement.SqlUpdate;\r
+import org.onap.holmes.common.api.entity.AlarmInfo;\r
+import org.onap.holmes.common.utils.AlarmInfoMapper;\r
+\r
+import java.util.List;\r
+\r
+@RegisterRowMapper(AlarmInfoMapper.class)\r
+public interface AlarmInfoDao {\r
+\r
+ @GetGeneratedKeys\r
+ @SqlUpdate("INSERT INTO ALARM_INFO (EVENTID,EVENTNAME,STARTEPOCHMICROSEC,SOURCEID,SOURCENAME,SEQUENCE,ALARMISCLEARED,ROOTFLAG,LASTEPOCHMICROSEC) VALUES (:eventId,:eventName,:startEpochMicroSec,:sourceId,:sourceName,:sequence,:alarmIsCleared,:rootFlag,:lastEpochMicroSec)")\r
+ String addAlarm(@BindBean AlarmInfo alarmInfo);\r
+\r
+ @SqlQuery("SELECT * FROM ALARM_INFO")\r
+ List<AlarmInfo> queryAlarm();\r
+\r
+ @SqlUpdate("DELETE FROM ALARM_INFO WHERE EVENTNAME=:eventName AND SOURCEID=:sourceId AND SOURCENAME=:sourceName")\r
+ int deleteAlarmByAlarmIsCleared(@Bind("eventName") String eventName,\r
+ @Bind("sourceId") String sourceId,\r
+ @Bind("sourceName") String sourceName);\r
+}\r
/**
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.holmes.engine.db;
+package org.onap.holmes.engine.db.jdbi;
-import java.util.List;
+import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
+import org.jdbi.v3.sqlobject.customizer.Bind;
+import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.onap.holmes.common.api.entity.CorrelationRule;
import org.onap.holmes.common.utils.CorrelationRuleMapper;
-import org.skife.jdbi.v2.sqlobject.Bind;
-import org.skife.jdbi.v2.sqlobject.SqlQuery;
-import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
-
-@RegisterMapper(CorrelationRuleMapper.class)
-public abstract class CorrelationRuleDao {
+import java.util.List;
+@RegisterRowMapper(CorrelationRuleMapper.class)
+public interface CorrelationRuleDao {
@SqlQuery("SELECT * FROM APLUS_RULE WHERE enable=:enable")
- public abstract List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable);
-
- public List<CorrelationRule> queryRuleByRuleEnable(int enable) {
- return queryRuleByEnable(enable);
- }
+ public List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable);
}
import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
import org.onap.holmes.common.dcae.utils.DcaeConfigurationParser;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.Md5Util;
+import org.onap.holmes.common.utils.SpringContextUtil;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
import org.onap.holmes.engine.dmaap.SubscriberAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.HashMap;
import java.util.Map;
public class ConfigFileScanningTask implements Runnable {
final private static Logger LOGGER = LoggerFactory.getLogger(ConfigFileScanningTask.class);
private String configFile = "/opt/hemtopics/cfy.json";
private ConfigFileScanner configFileScanner;
- private String prevConfigMd5 = Md5Util.md5(null);
+ private String prevConfigMd5 = Md5Util.md5(new HashMap<String, String>());
public ConfigFileScanningTask(ConfigFileScanner configFileScanner) {
this.configFileScanner = configFileScanner;
}
private void addSubscribers(DcaeConfigurations dcaeConfigurations) {
- SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
- .getService(SubscriberAction.class);
+ SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
for (String key : dcaeConfigurations.getSubKeys()) {
Subscriber subscriber = new Subscriber();
subscriber.setTopic(key);
/**
* 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
- *
- * 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.
import org.onap.holmes.common.dcae.DcaeConfigurationQuery;
import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.Md5Util;
+import org.onap.holmes.common.utils.SpringContextUtil;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
import org.onap.holmes.engine.dmaap.SubscriberAction;
try {
dcaeConfigurations = DcaeConfigurationQuery.getDcaeConfigurations(hostname);
String md5 = Md5Util.md5(dcaeConfigurations);
- if (prevConfigMd5.equals(md5)){
+ if (prevConfigMd5.equals(md5)) {
log.info("Operation aborted due to identical Configurations.");
return;
}
}
private void addSubscribers(DcaeConfigurations dcaeConfigurations) {
- SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
- .getService(SubscriberAction.class);
+ SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
for (String key : dcaeConfigurations.getSubKeys()) {
Subscriber subscriber = new Subscriber();
subscriber.setTopic(key);
import org.onap.holmes.common.exception.AlarmInfoException;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
import org.onap.holmes.engine.manager.DroolsEngine;
-import java.util.ArrayList;
import java.util.List;
@Slf4j
private Subscriber subscriber;
private DroolsEngine droolsEngine;
private volatile boolean isAlive = true;
- private AlarmInfoDao alarmInfoDao;
+ private AlarmInfoDaoService alarmInfoDaoService;
- public DMaaPAlarmPolling(Subscriber subscriber, DroolsEngine droolsEngine, AlarmInfoDao alarmInfoDao) {
+ public DMaaPAlarmPolling(Subscriber subscriber, DroolsEngine droolsEngine, AlarmInfoDaoService alarmInfoDaoService) {
this.subscriber = subscriber;
this.droolsEngine = droolsEngine;
- this.alarmInfoDao = alarmInfoDao;
+ this.alarmInfoDaoService = alarmInfoDaoService;
}
public void run() {
try {
AlarmInfo alarmInfo = getAlarmInfo(vesAlarm);
if (alarmInfo.getAlarmIsCleared() != 1) {
- alarmInfoDao.saveAlarm(alarmInfo);
+ alarmInfoDaoService.saveAlarm(alarmInfo);
} else {
- alarmInfoDao.deleteAlarm(alarmInfo);
+ alarmInfoDaoService.deleteAlarm(alarmInfo);
}
droolsEngine.putRaisedIntoStream(vesAlarm);
/*
- * Copyright 2017 - 2021 ZTE Corporation.
+ * Copyright 2017 - 2022 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
package org.onap.holmes.engine.dmaap;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
+import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.onap.holmes.common.database.DbDaoUtil;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
+import org.onap.holmes.engine.db.jdbi.AlarmInfoDao;
import org.onap.holmes.engine.manager.DroolsEngine;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
-@Service
+@Component
@Slf4j
public class SubscriberAction {
- @Inject
+ @Autowired
private DroolsEngine droolsEngine;
- @Inject
+ @Autowired
private DbDaoUtil daoUtil;
+ @Autowired
+ private AlarmInfoDaoService alarmInfoDaoService;
+
private HashMap<String, DMaaPAlarmPolling> pollingTasks = new HashMap<>();
public synchronized void addSubscriber(Subscriber subscriber) {
removeSubscriber(subscriber);
}
AlarmInfoDao alarmInfoDao = daoUtil.getJdbiDaoByOnDemand(AlarmInfoDao.class);
- DMaaPAlarmPolling pollingTask = new DMaaPAlarmPolling(subscriber, droolsEngine, alarmInfoDao);
+ DMaaPAlarmPolling pollingTask = new DMaaPAlarmPolling(subscriber, droolsEngine, alarmInfoDaoService);
Thread thread = new Thread(pollingTask);
thread.start();
pollingTasks.put(topic, pollingTask);
public void stopPollingTasks() {
Iterator iterator = pollingTasks.entrySet().iterator();
while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry)iterator.next();
+ Map.Entry entry = (Map.Entry) iterator.next();
String key = (String) entry.getKey();
pollingTasks.get(key).stopTask();
}
import lombok.extern.slf4j.Slf4j;
import org.drools.compiler.kie.builder.impl.InternalKieModule;
import org.drools.core.util.StringUtils;
-import org.jvnet.hk2.annotations.Service;
import org.kie.api.KieServices;
import org.kie.api.builder.*;
import org.kie.api.builder.Message.Level;
import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
import org.onap.holmes.common.exception.AlarmInfoException;
import org.onap.holmes.common.exception.CorrelationException;
-import org.onap.holmes.common.utils.DbDaoUtil;
import org.onap.holmes.common.utils.ExceptionUtil;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
import org.onap.holmes.engine.request.DeployRuleRequest;
import org.onap.holmes.engine.wrapper.RuleMgtWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
-@Service
-public class DroolsEngine {
-
+@Component
+public class DroolsEngine implements ApplicationRunner {
private final static int ENABLE = 1;
private final Map<String, String> deployed = new ConcurrentHashMap<>();
private RuleMgtWrapper ruleMgtWrapper;
- private DbDaoUtil daoUtil;
private ClosedLoopControlNameCache closedLoopControlNameCache;
- private AlarmInfoDao alarmInfoDao;
+ private AlarmInfoDaoService alarmInfoDaoService;
private KieServices ks = KieServices.Factory.get();
private ReleaseId releaseId = ks.newReleaseId("org.onap.holmes", "rules", "1.0.0-SNAPSHOT");
private ReleaseId compilationRelease = ks.newReleaseId("org.onap.holmes", "compilation", "1.0.0-SNAPSHOT");
private KieSession session;
private String instanceIp;
- @Inject
- public void setRuleMgtWrapper(RuleMgtWrapper ruleMgtWrapper) {
- this.ruleMgtWrapper = ruleMgtWrapper;
+ @Autowired
+ public void setAlarmInfoDaoService(AlarmInfoDaoService alarmInfoDaoService) {
+ this.alarmInfoDaoService = alarmInfoDaoService;
}
- @Inject
- public void setDaoUtil(DbDaoUtil daoUtil) {
- this.daoUtil = daoUtil;
+ @Autowired
+ public void setRuleMgtWrapper(RuleMgtWrapper ruleMgtWrapper) {
+ this.ruleMgtWrapper = ruleMgtWrapper;
}
- @Inject
+ @Autowired
public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
this.closedLoopControlNameCache = closedLoopControlNameCache;
}
- @PostConstruct
- private void init() {
- alarmInfoDao = daoUtil.getJdbiDaoByOnDemand(AlarmInfoDao.class);
+ @Override
+ public void run(ApplicationArguments args) {
instanceIp = MicroServiceConfig.getMicroServiceIpAndPort()[0];
try {
log.info("Drools engine initializing...");
}
public void syncAlarms() throws AlarmInfoException {
- alarmInfoDao.queryAllAlarm().forEach(alarmInfo -> putRaisedIntoStream(convertAlarmInfo2VesAlarm(alarmInfo)));
+ alarmInfoDaoService.queryAllAlarm().forEach(alarmInfo -> putRaisedIntoStream(convertAlarmInfo2VesAlarm(alarmInfo)));
}
public String deployRule(DeployRuleRequest rule) throws CorrelationException {
Resource jarRes = ks.getResources().newByteArrayResource(jar);
return ks.getRepository().addKieModule(jarRes);
}
-
}
package org.onap.holmes.engine.manager.status;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.engine.entity.EngineEntity;
import org.onap.holmes.common.engine.service.EngineEntityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
-import javax.inject.Inject;
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import static java.util.concurrent.TimeUnit.SECONDS;
-@Service
+@Component
public class EntityStatusRefreshTask extends TimerTask {
private static final Logger logger = LoggerFactory.getLogger(EntityStatusRefreshTask.class);
private final long INTERVAL = SECONDS.toMillis(15);
private Timer timer = new Timer("EntityStatusRefreshTimer", true);
private EngineEntityService engineEntityService;
- @Inject
+ @Autowired
public EntityStatusRefreshTask(EngineEntityService engineEntityService) {
this.engineEntityService = engineEntityService;
}
/**
* 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.
*/
package org.onap.holmes.engine.request;
-import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
+import javax.validation.constraints.NotNull;
+
@Getter
@Setter
public class CompileRuleRequest {
/**
- * Copyright 2017 ZTE Corporation.
- *
+ * 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
- *
- * 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.
*/
package org.onap.holmes.engine.request;
-import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
+import javax.validation.constraints.NotNull;
+
@Getter
@Setter
public class DeployRuleRequest {
@NotNull
private String content;
+ @NotNull
private String engineId;
@NotNull
package org.onap.holmes.engine.request;
-import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
+import javax.validation.constraints.NotNull;
+
@Getter
@Setter
public class DmaapConfigRequest {
/*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.MediaType;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
import org.onap.holmes.common.dcae.entity.SecurityInfo;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
+import org.onap.holmes.common.utils.SpringContextUtil;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
import org.onap.holmes.engine.dmaap.SubscriberAction;
import org.onap.holmes.engine.request.DmaapConfigRequest;
+import org.springframework.web.bind.annotation.*;
-@Service
@Slf4j
-//@Api(tags = {"DMaaP Configurations"})
-@Path("/dmaap")
+@RestController
+@RequestMapping("/dmaap")
public class DmaapConfigurationService {
- @PUT
- @Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Subscribe to a new topic. "
+ "If the topic already exists, it is replaced with the new configuration.")
- @Path("/sub")
+ @RequestMapping(value = "/sub", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON)
public String addSubInfo(
- @ApiParam (value = "A JSON object with the fields named <b>name</b>"
- + " and <b>url</b>. Both fields are required.") DmaapConfigRequest config,
- @Context HttpServletRequest request){
+ @ApiParam(value = "A JSON object with the fields named <b>name</b>"
+ + " and <b>url</b>. Both fields are required.")
+ @RequestBody DmaapConfigRequest config) {
String url = config.getUrl();
if (url.startsWith("http://") || url.startsWith("https://")) {
Subscriber subscriber = new Subscriber();
subscriber.setTopic(config.getName());
subscriber.setUrl(url);
- SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
- .getService(SubscriberAction.class);
+ SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
subscriberAction.removeSubscriber(subscriber);
subscriberAction.addSubscriber(subscriber);
return "{\"message\": \"Only the HTTP or HTTPS protocol is supported!\"}";
}
- @DELETE
@Path("/sub/{topic}")
@ApiOperation(value = "Unsubscribe a topic from DMaaP.")
- @Produces(MediaType.APPLICATION_JSON)
- public String removeSubInfo(@PathParam("topic") String topic){
+ @RequestMapping(value = "/sub/{topic}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON)
+ public String removeSubInfo(@PathVariable("topic") String topic) {
Subscriber subscriber = new Subscriber();
subscriber.setTopic(topic);
- SubscriberAction subscriberAction = ServiceLocatorHolder.getLocator()
- .getService(SubscriberAction.class);
+ SubscriberAction subscriberAction = SpringContextUtil.getBean(SubscriberAction.class);
subscriberAction.removeSubscriber(subscriber);
return "{\"message\": \"Topic unsubscribed.\"}";
}
- @PUT
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/pub")
@ApiOperation(value = "Add/Update a publishing topic. "
+ "If the topic already exists, it is replaced with the new configuration.")
+ @RequestMapping(value = "/pub", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON)
public String updatePubInfo(
- @ApiParam (value = "A JSON object with the fields named <b>name</b>"
- + " and <b>url</b>. Both fields are required.") DmaapConfigRequest config,
- @Context HttpServletRequest request){
+ @ApiParam(value = "A JSON object with the fields named <b>name</b>"
+ + " and <b>url</b>. Both fields are required.")
+ @RequestBody DmaapConfigRequest config) {
String url = config.getUrl();
if (url.startsWith("http://") || url.startsWith("https://")) {
SecurityInfo securityInfo = new SecurityInfo();
/**
* 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
- *
+ * <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.
package org.onap.holmes.engine.resources;
-import com.codahale.metrics.annotation.Timed;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.ExceptionUtil;
-import org.onap.holmes.common.utils.LanguageUtil;
import org.onap.holmes.engine.manager.DroolsEngine;
import org.onap.holmes.engine.request.CompileRuleRequest;
import org.onap.holmes.engine.request.DeployRuleRequest;
import org.onap.holmes.engine.response.CorrelationRuleResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import java.util.Locale;
+import jakarta.ws.rs.core.MediaType;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-@Service
-@Path("/rule")
-@Api(tags = {"Holmes Engine Management"})
-@Produces(MediaType.APPLICATION_JSON)
@Slf4j
+@RestController
+@RequestMapping("/rule")
+@Api(tags = {"Holmes Engine Management"})
public class EngineResources {
- @Inject
- DroolsEngine droolsEngine;
- private Pattern packagePattern = Pattern.compile("package[\\s]+([^;]+)[;\\s]*");
+ private Pattern packagePattern = Pattern.compile("package[\\s]+([^;]+)[;\\s]*");
private ClosedLoopControlNameCache closedLoopControlNameCache;
+ private DroolsEngine droolsEngine;
+
+ @Autowired
+ public void setDroolsEngine(DroolsEngine droolsEngine) {
+ this.droolsEngine = droolsEngine;
+ }
- @Inject
+ @Autowired
public void setClosedLoopControlNameCache(ClosedLoopControlNameCache closedLoopControlNameCache) {
this.closedLoopControlNameCache = closedLoopControlNameCache;
}
- @PUT
- @Produces(MediaType.APPLICATION_JSON)
- @Timed
+ @ResponseBody
+ @PutMapping(produces = MediaType.APPLICATION_JSON)
public CorrelationRuleResponse deployRule(
@ApiParam(value = "The request entity of the HTTP call, which comprises three "
+ "fields: \"content\" , \"loopControlName\" and \"engineId\". "
+ "The \"content\" should be a valid Drools rule string and the \"engineId\" "
- + "has to be \"engine-d\" in the Amsterdam release.", required = true) DeployRuleRequest deployRuleRequest,
- @Context HttpServletRequest httpRequest) {
+ + "has to be \"engine-d\" in the Amsterdam release.", required = true)
+ @RequestBody DeployRuleRequest deployRuleRequest) {
CorrelationRuleResponse crResponse = new CorrelationRuleResponse();
- Locale locale = LanguageUtil.getLocale(httpRequest);
try {
String packageName = getPackageName(deployRuleRequest.getContent());
- if(packageName == null) {
- throw new CorrelationException("Could not find package name in rule: "+deployRuleRequest.getContent());
+ if (packageName == null) {
+ throw new CorrelationException("Could not find package name in rule: " + deployRuleRequest.getContent());
}
-
+
closedLoopControlNameCache
.put(packageName, deployRuleRequest.getLoopControlName());
String packageNameRet = droolsEngine.deployRule(deployRuleRequest);
return crResponse;
}
- @DELETE
- @Produces(MediaType.APPLICATION_JSON)
- @Timed
- @Path("/{packageName}")
- public boolean undeployRule(@PathParam("packageName") String packageName,
- @Context HttpServletRequest httpRequest) {
-
- Locale locale = LanguageUtil.getLocale(httpRequest);
-
+ @DeleteMapping(value = "/{packageName}")
+ public void undeployRule(@PathVariable("packageName") String packageName) {
try {
droolsEngine.undeployRule(packageName);
closedLoopControlNameCache.remove(packageName);
log.error(correlationException.getMessage(), correlationException);
throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage());
}
-
- return true;
}
-
- @POST
+ @PostMapping
@ApiOperation(value = "Check the validity of a rule.")
- @Produces(MediaType.APPLICATION_JSON)
- @Timed
- public boolean compileRule(CompileRuleRequest compileRuleRequest,
- @Context HttpServletRequest httpRequest) {
-
- Locale locale = LanguageUtil.getLocale(httpRequest);
-
+ public void compileRule(@RequestBody CompileRuleRequest compileRuleRequest) {
try {
droolsEngine.compileRule(compileRuleRequest.getContent());
} catch (CorrelationException correlationException) {
log.error(correlationException.getMessage(), correlationException);
throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage());
}
- return true;
}
-
- private String getPackageName(String contents){
+
+ private String getPackageName(String contents) {
Matcher m = packagePattern.matcher(contents);
-
- if (m.find( )) {
- return m.group(1);
- }else {
- return null;
+
+ if (m.find()) {
+ return m.group(1);
+ } else {
+ return null;
}
}
}
/*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.SwaggerDefinition;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
-@Service
+@RestController
@SwaggerDefinition
-@Path("/healthcheck")
+@RequestMapping("/healthcheck")
@Api(tags = {"Health Check"})
-@Produces(MediaType.TEXT_PLAIN)
-@Slf4j
public class HealthCheck {
- @GET
- @Produces(MediaType.TEXT_PLAIN)
+ @GetMapping
@ApiOperation(value = "Interface for the health check of the engine management module for Holmes")
- public boolean healthCheck(){
- return true;
+ public void healthCheck() {
}
}
/*
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2022 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.holmes.engine.resources;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import jakarta.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.net.URLDecoder;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
-@Service
-@Path("/swagger.json")
-@Produces(MediaType.APPLICATION_JSON)
@Slf4j
+@RestController
+@RequestMapping("/swagger.json")
public class SwaggerResource {
- @GET
- @Produces(MediaType.APPLICATION_JSON)
+ @GetMapping(produces = MediaType.APPLICATION_JSON)
public String getSwaggerJson() {
URL url = SwaggerResource.class.getResource("/swagger.json");
String ret = "{}";
return ret;
}
- try(BufferedReader br = new BufferedReader(new FileReader(file))) {
+ try (BufferedReader br = new BufferedReader(new FileReader(file))) {
StringBuffer buffer = new StringBuffer();
String line = " ";
while ((line = br.readLine()) != null) {
/**
* 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.
/**
* 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.
*/
package org.onap.holmes.engine.utils;
+import org.onap.holmes.common.api.stat.Alarm;
+
import java.util.HashMap;
import java.util.Map;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.api.stat.Alarm;
-@Service
public class AlarmUtil {
private final static AlarmUtil alarmUtil = new AlarmUtil();
* Map<ruleId, <ProbableCause-EquipType, priority>>
*/
private final Map<String, Map<String, Integer>> rootPriorityMap =
- new HashMap<String, Map<String, Integer>>();
+ new HashMap<String, Map<String, Integer>>();
/**
* Map<rule, ProbableCause+EquipType+priority>
*/
String[] probableCauseStrs = probableCauseStr.replace(" ", "").split(",");
for (int i = 0; i < probableCauseStrs.length; i++) {
if (alarm.getProbableCause() == Long.parseLong(probableCauseStrs[i])
- && alarm.getEquipType().equals(equipTypes[i])) {
+ && alarm.getEquipType().equals(equipTypes[i])) {
return true;
}
}
}
public Integer getPriority(String ruleId, String probableCauseStr, String rootAlarmFeatureStr,
- String equipTypeStr, Alarm alarm) {
+ String equipTypeStr, Alarm alarm) {
if (rootPriorityMap.containsKey(ruleId)) {
if (!saveRuleMsg.get(ruleId)
- .equals(probableCauseStr + equipTypeStr + rootAlarmFeatureStr)) {
+ .equals(probableCauseStr + equipTypeStr + rootAlarmFeatureStr)) {
setPriority(ruleId, probableCauseStr, rootAlarmFeatureStr, equipTypeStr);
}
} else {
}
Integer priority =
- rootPriorityMap.get(ruleId).get(alarm.getProbableCause() + "-" + alarm.getEquipType());
+ rootPriorityMap.get(ruleId).get(alarm.getProbableCause() + "-" + alarm.getEquipType());
if (priority == null) {
priority = 0;
}
}
private void setPriority(String ruleId, String probableCauseStr, String rootAlarmFeatureStr,
- String equipTypeStr) {
+ String equipTypeStr) {
saveRuleMsg.put(ruleId, probableCauseStr + equipTypeStr + rootAlarmFeatureStr);
Map<String, Integer> map = new HashMap<String, Integer>();
String[] equipTypes = equipTypeStr.replace(" ", "").split(",");
for (int i = 0; i < rootAlarmFeatureStrs.length; i++) {
map.put(probableCauseStrs[i] + "-" + equipTypes[i],
- Integer.parseInt(rootAlarmFeatureStrs[i]));
+ Integer.parseInt(rootAlarmFeatureStrs[i]));
}
rootPriorityMap.put(ruleId, map);
/**
* 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.
*/
package org.onap.holmes.engine.wrapper;
-import java.util.List;
-import javax.inject.Inject;
-import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
-import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.engine.db.CorrelationRuleDao;
import org.onap.holmes.common.api.entity.CorrelationRule;
import org.onap.holmes.common.exception.CorrelationException;
-import org.onap.holmes.common.utils.DbDaoUtil;
+import org.onap.holmes.engine.db.CorrelationRuleDaoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
@Service
-@Singleton
@Slf4j
public class RuleMgtWrapper {
+ private CorrelationRuleDaoService correlationRuleDaoService;
- @Inject
- private DbDaoUtil daoUtil;
+ @Autowired
+ public RuleMgtWrapper(CorrelationRuleDaoService correlationRuleDaoService) {
+ this.correlationRuleDaoService = correlationRuleDaoService;
+ }
public List<CorrelationRule> queryRuleByEnable(int enable) throws CorrelationException {
- List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class)
- .queryRuleByRuleEnable(enable);
+ List<CorrelationRule> ruleTemp = correlationRuleDaoService.queryRuleByRuleEnable(enable);
return ruleTemp;
}
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration debug="false">
+ <property name="LOG_HOME" value="/var/log/ONAP/holmes"/>
+ <property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss SSS} %-5p [%c][%t] - %msg%n" />
+
+ <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>${LOG_PATTERN}</pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>debug</level>
+ </filter>
+ </appender>
+
+ <appender name="FileOutputForDebug" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${LOG_HOME}/holmes-engine-mgmt-debug.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOG_HOME}/archived/holmes-engine-mgmt-debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
+ <maxHistory>15</maxHistory>
+ <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <maxFileSize>100MB</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
+ </rollingPolicy>
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>${LOG_PATTERN}</pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>info</level>
+ </filter>
+ </appender>
+
+ <appender name="FileOutputForError" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${LOG_HOME}/holmes-engine-mgmt-error.log</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>${LOG_HOME}/archived/holmes-engine-mgmt-error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
+ <maxHistory>15</maxHistory>
+ <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <maxFileSize>10MB</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
+ </rollingPolicy>
+ <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+ <pattern>${LOG_PATTERN}</pattern>
+ <charset>UTF-8</charset>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.LevelFilter">
+ <level>error</level>
+ <onMatch>deny</onMatch>
+ <onMismatch>accept</onMismatch>
+ </filter>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="Console" />
+ <appender-ref ref="FileOutputForDebug" />
+ <appender-ref ref="FileOutputForError" />
+ </root>
+</configuration>
\ No newline at end of file
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.onap.holmes.common.api.stat.AlarmAdditionalField;
import org.onap.holmes.common.api.stat.VesAlarm;
import org.powermock.core.classloader.annotations.PrepareForTest;
*/
package org.onap.holmes.dsa.dmaappolling;
-import org.glassfish.hk2.api.ServiceLocator;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-import org.onap.holmes.common.api.stat.AlarmAdditionalField;
import org.onap.holmes.common.api.stat.VesAlarm;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.JerseyClient;
+import org.onap.holmes.common.utils.SpringContextUtil;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.ArrayList;
-import java.util.List;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import static org.easymock.EasyMock.*;
import static org.junit.Assert.assertThat;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({ServiceLocatorHolder.class, JerseyClient.class})
+@PrepareForTest({SpringContextUtil.class, JerseyClient.class})
@PowerMockIgnore("javax.net.ssl.*")
public class SubscriberTest {
@Before
public void init() {
- PowerMock.mockStatic(ServiceLocatorHolder.class);
- ServiceLocator serviceLocator = PowerMock.createMock(ServiceLocator.class);
- expect(ServiceLocatorHolder.getLocator()).andReturn(serviceLocator).anyTimes();
- expect(serviceLocator.getService(DMaaPResponseUtil.class)).andReturn(util).anyTimes();
+ PowerMock.mockStatic(SpringContextUtil.class);
+ expect(SpringContextUtil.getBean(DMaaPResponseUtil.class)).andReturn(util).anyTimes();
}
@Test
vesAlarm.setStartEpochMicrosec(500L);
vesAlarm.setVersion("4.0");
Map alarmAdditionalFields = new HashMap<String, String>();
- alarmAdditionalFields.put("addInfo", "addInfo");
- vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
- vesAlarm.setAlarmCondition("alarmCondition");
+ alarmAdditionalFields.put("addInfo", "addInfo");
+ vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
+ vesAlarm.setAlarmCondition("alarmCondition");
vesAlarm.setAlarmInterfaceA("alarmInterfaceA");
vesAlarm.setEventCategory("eventCategory");
vesAlarm.setEventSeverity("eventSeverity");
vesAlarm.setStartEpochMicrosec(500L);
vesAlarm.setVersion("4.0");
Map alarmAdditionalFields = new HashMap<String, String>();
- alarmAdditionalFields.put("addInfo", "addInfo");
- vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
- vesAlarm.setAlarmCondition("alarmCondition");
+ alarmAdditionalFields.put("addInfo", "addInfo");
+ vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
+ vesAlarm.setAlarmCondition("alarmCondition");
vesAlarm.setAlarmInterfaceA("alarmInterfaceA");
vesAlarm.setEventCategory("eventCategory");
vesAlarm.setEventSeverity("eventSeverity");
+++ /dev/null
-/**\r
- * Copyright 2017 ZTE Corporation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.holmes.engine;\r
-\r
-import io.dropwizard.db.DataSourceFactory;\r
-import org.hamcrest.core.IsEqual;\r
-import org.hamcrest.core.IsNull;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.powermock.api.easymock.PowerMock;\r
-\r
-public class EnginedAppConfigTest {\r
-\r
- private EngineDAppConfig engineAppConfig;\r
-\r
- @Before\r
- public void setUp() {\r
- engineAppConfig = new EngineDAppConfig();\r
- }\r
-\r
- @Test\r
- public void getDataSourceFactory() {\r
- Assert.assertThat(engineAppConfig.getDataSourceFactory(), IsNull.<DataSourceFactory>notNullValue());\r
- }\r
-\r
- @Test\r
- public void setDataSourceFactory() {\r
- DataSourceFactory database = new DataSourceFactory();\r
- engineAppConfig.setDataSourceFactory(database);\r
- Assert.assertThat(engineAppConfig.getDataSourceFactory(), IsEqual.equalTo(database));\r
- }\r
-\r
- @Test\r
- public void getApidescription() {\r
- final String apidescription = "Holmes rule management rest API";\r
- Assert.assertThat(engineAppConfig.getApidescription(), IsEqual.equalTo(apidescription));\r
- }\r
-\r
- @Test\r
- public void setApidescription() {\r
- final String apidescription = "set api description";\r
- engineAppConfig.setApidescription(apidescription);\r
- Assert.assertThat(engineAppConfig.getApidescription(), IsEqual.equalTo(apidescription));\r
- }\r
-}\r
/**
- * Copyright 2020 ZTE Corporation.
+ * Copyright 2020-2022 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
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.internal.WhiteboxImpl;
import java.util.concurrent.TimeUnit;
setReadyFlagAfter(3);
- WhiteboxImpl.invokeMethod(initializer, "init");
+ initializer.run(null);
TimeUnit.SECONDS.sleep(6);
/**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2022 ZTE Corporation.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
package org.onap.holmes.engine.db;\r
\r
import org.easymock.EasyMock;\r
-import org.hamcrest.core.IsNot;\r
import org.hamcrest.core.IsNull;\r
import org.junit.Assert;\r
import org.junit.Before;\r
-import org.junit.Rule;\r
import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
import org.onap.holmes.common.api.entity.AlarmInfo;\r
-import org.onap.holmes.common.exception.AlarmInfoException;\r
import org.powermock.api.easymock.PowerMock;\r
\r
import java.util.ArrayList;\r
public class AlarmInfoDaoTest {\r
\r
\r
- private AlarmInfoDao alarmInfoDao;\r
+ private AlarmInfoDaoService alarmInfoDaoService;\r
\r
@Before\r
public void setUp() {\r
- alarmInfoDao = PowerMock.createMock(AlarmInfoDao.class);\r
+ alarmInfoDaoService = PowerMock.createMock(AlarmInfoDaoService.class);\r
}\r
\r
@Test\r
public void queryAllAlarm() throws Exception {\r
\r
- EasyMock.expect(alarmInfoDao.queryAllAlarm()).andReturn(new ArrayList<AlarmInfo>());\r
+ EasyMock.expect(alarmInfoDaoService.queryAllAlarm()).andReturn(new ArrayList<AlarmInfo>());\r
PowerMock.replayAll();\r
\r
- List<AlarmInfo> alarmInfoList = alarmInfoDao.queryAllAlarm();\r
+ List<AlarmInfo> alarmInfoList = alarmInfoDaoService.queryAllAlarm();\r
PowerMock.verifyAll();\r
Assert.assertThat(alarmInfoList, IsNull.<List<AlarmInfo>>notNullValue());\r
}\r
import org.junit.Before;\r
import org.junit.Test;\r
import org.onap.holmes.common.api.entity.CorrelationRule;\r
+import org.onap.holmes.engine.db.jdbi.CorrelationRuleDao;\r
import org.powermock.api.easymock.PowerMock;\r
\r
import java.util.ArrayList;\r
package org.onap.holmes.engine.dcae;
import org.easymock.EasyMock;
-import org.glassfish.hk2.api.ServiceLocator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.holmes.common.dcae.DcaeConfigurationsCache;
-import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
+import org.onap.holmes.common.utils.SpringContextUtil;
import org.onap.holmes.dsa.dmaappolling.DMaaPResponseUtil;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
import org.onap.holmes.engine.dmaap.SubscriberAction;
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 static org.junit.Assert.assertThat;
@RunWith(PowerMockRunner.class)
+@PrepareForTest({SpringContextUtil.class})
public class ConfigFileScanningTaskTest {
@Test
public void run() {
- ServiceLocator mockedSl = PowerMock.createMock(ServiceLocator.class);
+ PowerMock.mockStatic(SpringContextUtil.class);
SubscriberAction mockedSa = PowerMock.createMock(SubscriberAction.class);
- ServiceLocatorHolder.setLocator(mockedSl);
- EasyMock.expect(mockedSl.getService(SubscriberAction.class)).andReturn(mockedSa);
+ EasyMock.expect(SpringContextUtil.getBean(SubscriberAction.class)).andReturn(mockedSa);
// This is invoked while executing new Subscriber().
- EasyMock.expect(mockedSl.getService(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
+ EasyMock.expect(SpringContextUtil.getBean(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
mockedSa.addSubscriber(EasyMock.anyObject(Subscriber.class));
EasyMock.expectLastCall();
@Test
public void run_config_not_changed() {
- ServiceLocator mockedSl = PowerMock.createMock(ServiceLocator.class);
+ PowerMock.mockStatic(SpringContextUtil.class);
SubscriberAction mockedSa = PowerMock.createMock(SubscriberAction.class);
- ServiceLocatorHolder.setLocator(mockedSl);
// mocked objects will be only used once
- EasyMock.expect(mockedSl.getService(SubscriberAction.class)).andReturn(mockedSa);
+ EasyMock.expect(SpringContextUtil.getBean(SubscriberAction.class)).andReturn(mockedSa);
// This is invoked while executing new Subscriber().
- EasyMock.expect(mockedSl.getService(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
+ EasyMock.expect(SpringContextUtil.getBean(DMaaPResponseUtil.class)).andReturn(new DMaaPResponseUtil());
mockedSa.addSubscriber(EasyMock.anyObject(Subscriber.class));
EasyMock.expectLastCall();
/**
- * Copyright 2017 ZTE Corporation.
- *
+ * 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
- *
- * 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.
*/
package org.onap.holmes.engine.dmaap;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Field;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.holmes.common.api.entity.AlarmInfo;
import org.onap.holmes.common.api.stat.VesAlarm;
import org.onap.holmes.dsa.dmaappolling.Subscriber;
-import org.onap.holmes.engine.db.AlarmInfoDao;
+import org.onap.holmes.engine.db.AlarmInfoDaoService;
import org.onap.holmes.engine.manager.DroolsEngine;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
-@PrepareForTest({Subscriber.class, DroolsEngine.class,DMaaPAlarmPolling.class})
+import java.lang.reflect.Field;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+@PrepareForTest({Subscriber.class, DroolsEngine.class, DMaaPAlarmPolling.class})
@RunWith(PowerMockRunner.class)
public class DMaaPAlarmPollingTest {
private DMaaPAlarmPolling dMaaPAlarmPolling;
private Subscriber subscriber;
private DroolsEngine droolsEngine;
- private AlarmInfoDao alarmInfoDao;
+ private AlarmInfoDaoService alarmInfoDaoService;
@Before
public void setUp() {
subscriber = PowerMock.createMock(Subscriber.class);
droolsEngine = PowerMock.createMock(DroolsEngine.class);
- alarmInfoDao = PowerMock.createMock(AlarmInfoDao.class);
- dMaaPAlarmPolling = new DMaaPAlarmPolling(subscriber, droolsEngine,alarmInfoDao);
+ alarmInfoDaoService = PowerMock.createMock(AlarmInfoDaoService.class);
+ dMaaPAlarmPolling = new DMaaPAlarmPolling(subscriber, droolsEngine, alarmInfoDaoService);
PowerMock.replayAll();
}
vesAlarm.setRootFlag(0);
PowerMock.replayAll();
- AlarmInfo alarmInfo = Whitebox.invokeMethod(dMaaPAlarmPolling,"getAlarmInfo",vesAlarm);
+ AlarmInfo alarmInfo = Whitebox.invokeMethod(dMaaPAlarmPolling, "getAlarmInfo", vesAlarm);
PowerMock.verifyAll();
assertThat(alarmInfo.getAlarmIsCleared(), is(1));
/**\r
- * Copyright 2017-2020 ZTE Corporation.\r
+ * Copyright 2017-2021 ZTE Corporation.\r
* <p>\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
package org.onap.holmes.engine.manager;\r
\r
-import org.junit.Before;\r
import org.junit.Rule;\r
import org.junit.Test;\r
import org.junit.rules.ExpectedException;\r
import org.onap.holmes.common.config.MicroServiceConfig;\r
import org.onap.holmes.common.dmaap.store.ClosedLoopControlNameCache;\r
import org.onap.holmes.common.exception.CorrelationException;\r
-import org.onap.holmes.common.utils.DbDaoUtil;\r
-import org.onap.holmes.engine.db.AlarmInfoDao;\r
+import org.onap.holmes.engine.db.AlarmInfoDaoService;\r
+import org.onap.holmes.engine.db.CorrelationRuleDaoService;\r
import org.onap.holmes.engine.request.DeployRuleRequest;\r
import org.onap.holmes.engine.wrapper.RuleMgtWrapper;\r
-import org.powermock.api.easymock.PowerMock;\r
import org.powermock.reflect.Whitebox;\r
\r
import java.util.ArrayList;\r
@Rule\r
public ExpectedException thrown = ExpectedException.none();\r
\r
- private RuleMgtWrapper ruleMgtWrapper;\r
+ private RuleMgtWrapper ruleMgtWrapperMock;\r
\r
private DroolsEngine droolsEngine;\r
\r
- private DbDaoUtil dbDaoUtilStub;\r
+ private AlarmInfoDaoService alarmInfoDaoServiceStub;\r
+\r
+ private CorrelationRuleDaoService correlationRuleDaoServiceStub;\r
\r
private ClosedLoopControlNameCache closedLoopControlNameCache;\r
\r
public DroolsEngineTest() throws Exception {\r
System.setProperty(MicroServiceConfig.HOSTNAME, "127.0.0.1:80");\r
droolsEngine = new DroolsEngine();\r
- ruleMgtWrapper = new RuleMgtWrapperStub();\r
- dbDaoUtilStub = new DbDaoUtilStub();\r
+ alarmInfoDaoServiceStub = new AlarmInfoDaoServiceStub();\r
+ droolsEngine.setAlarmInfoDaoService(alarmInfoDaoServiceStub);\r
+ correlationRuleDaoServiceStub = new CorrelationRuleDaoServiceStub();\r
+ ruleMgtWrapperMock = new RuleMgtWrapperStub(correlationRuleDaoServiceStub);\r
closedLoopControlNameCache = new ClosedLoopControlNameCache();\r
droolsEngine.setClosedLoopControlNameCache(closedLoopControlNameCache);\r
- droolsEngine.setDaoUtil(dbDaoUtilStub);\r
- droolsEngine.setRuleMgtWrapper(ruleMgtWrapper);\r
+ droolsEngine.setRuleMgtWrapper(ruleMgtWrapperMock);\r
\r
- Whitebox.invokeMethod(droolsEngine, "init");\r
+ Whitebox.invokeMethod(droolsEngine, "run", null);\r
System.clearProperty(MicroServiceConfig.HOSTNAME);\r
}\r
\r
- @Before\r
- public void setUp() throws Exception {\r
- PowerMock.resetAll();\r
- }\r
-\r
@Test\r
public void deployRule_rule_is_null() throws CorrelationException {\r
thrown.expect(NullPointerException.class);\r
\r
assertThat(packages.contains("packageCheck"), is(true));\r
}\r
-}\r
-\r
-class RuleMgtWrapperStub extends RuleMgtWrapper {\r
- private List<CorrelationRule> rules;\r
-\r
- public RuleMgtWrapperStub() {\r
- rules = new ArrayList<>();\r
- CorrelationRule rule = new CorrelationRule();\r
- rule.setEnabled(1);\r
- rule.setContent("package org.onap.holmes;");\r
- rule.setPackageName("UT");\r
- rule.setClosedControlLoopName(UUID.randomUUID().toString());\r
- rule.setEngineInstance("127.0.0.1");\r
- rules.add(rule);\r
- }\r
-\r
- public List<CorrelationRule> getRules() {\r
- return rules;\r
- }\r
-\r
- public void setRules(List<CorrelationRule> rules) {\r
- this.rules = rules;\r
- }\r
\r
- @Override\r
- public List<CorrelationRule> queryRuleByEnable(int enabled) throws CorrelationException {\r
- return rules.stream().filter(rule -> rule.getEnabled() == enabled).collect(Collectors.toList());\r
+ class RuleMgtWrapperStub extends RuleMgtWrapper {\r
+ private List<CorrelationRule> rules;\r
+\r
+ public RuleMgtWrapperStub(CorrelationRuleDaoService correlationRuleDaoService) {\r
+ super(correlationRuleDaoService);\r
+ rules = new ArrayList<>();\r
+ CorrelationRule rule = new CorrelationRule();\r
+ rule.setEnabled(1);\r
+ rule.setContent("package org.onap.holmes;");\r
+ rule.setPackageName("UT");\r
+ rule.setClosedControlLoopName(UUID.randomUUID().toString());\r
+ rule.setEngineInstance("127.0.0.1");\r
+ rules.add(rule);\r
+ }\r
+\r
+ public List<CorrelationRule> getRules() {\r
+ return rules;\r
+ }\r
+\r
+ public void setRules(List<CorrelationRule> rules) {\r
+ this.rules = rules;\r
+ }\r
+\r
+ @Override\r
+ public List<CorrelationRule> queryRuleByEnable(int enabled) throws CorrelationException {\r
+ return rules.stream().filter(rule -> rule.getEnabled() == enabled).collect(Collectors.toList());\r
+ }\r
}\r
-}\r
\r
-class AlarmInfoDaoStub extends AlarmInfoDao {\r
-\r
- private List<AlarmInfo> alarms;\r
-\r
- public AlarmInfoDaoStub() {\r
- alarms = new ArrayList<>();\r
- AlarmInfo info = new AlarmInfo();\r
- info.setEventId("eventId");\r
- info.setEventName("eventName");\r
- info.setStartEpochMicroSec(1L);\r
- info.setLastEpochMicroSec(1L);\r
- info.setSourceId("sourceId");\r
- info.setSourceName("sourceName");\r
- info.setRootFlag(0);\r
- info.setAlarmIsCleared(1);\r
- alarms.add(info);\r
+ class AlarmInfoDaoServiceStub extends AlarmInfoDaoService {\r
+\r
+ private List<AlarmInfo> alarms;\r
+\r
+ public AlarmInfoDaoServiceStub() {\r
+ alarms = new ArrayList<>();\r
+ AlarmInfo info = new AlarmInfo();\r
+ info.setEventId("eventId");\r
+ info.setEventName("eventName");\r
+ info.setStartEpochMicroSec(1L);\r
+ info.setLastEpochMicroSec(1L);\r
+ info.setSourceId("sourceId");\r
+ info.setSourceName("sourceName");\r
+ info.setRootFlag(0);\r
+ info.setAlarmIsCleared(1);\r
+ alarms.add(info);\r
+ }\r
+\r
+ @Override\r
+ public AlarmInfo saveAlarm(AlarmInfo alarmInfo) {\r
+ alarms.add(alarmInfo);\r
+ return alarmInfo;\r
+ }\r
+\r
+ @Override\r
+ public List<AlarmInfo> queryAllAlarm() {\r
+ return alarms;\r
+ }\r
+\r
+ @Override\r
+ public void deleteAlarm(AlarmInfo alarmInfo) {\r
+\r
+ }\r
}\r
\r
- @Override\r
- protected String addAlarm(AlarmInfo alarmInfo) {\r
- alarms.add(alarmInfo);\r
- return null;\r
- }\r
-\r
- @Override\r
- protected List<AlarmInfo> queryAlarm() {\r
- return alarms;\r
- }\r
+ class CorrelationRuleDaoServiceStub extends CorrelationRuleDaoService {\r
\r
- @Override\r
- protected int deleteAlarmByAlarmIsCleared(String alarmName, String sourceName, String sourceId) {\r
- return 1;\r
}\r
}\r
\r
-class DbDaoUtilStub extends DbDaoUtil {\r
- private AlarmInfoDao dao = new AlarmInfoDaoStub();\r
\r
- @Override\r
- public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {\r
-\r
- return (T) dao;\r
-\r
- }\r
-}\r
import org.onap.holmes.engine.request.CompileRuleRequest;\r
import org.onap.holmes.engine.request.DeployRuleRequest;\r
import org.powermock.api.easymock.PowerMock;\r
-import org.powermock.reflect.Whitebox;\r
\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.ws.rs.WebApplicationException;\r
-import java.util.Locale;\r
+import jakarta.ws.rs.WebApplicationException;\r
\r
import static org.easymock.EasyMock.*;\r
\r
closedLoopControlNameCache = new ClosedLoopControlNameCache();\r
engineResources = new EngineResources();\r
engineResources.setClosedLoopControlNameCache(closedLoopControlNameCache);\r
-\r
- Whitebox.setInternalState(engineResources,"droolsEngine", droolsEngine);\r
+ engineResources.setDroolsEngine(droolsEngine);\r
PowerMock.resetAll();\r
}\r
\r
@Test\r
public void deployRule_exception() throws CorrelationException {\r
DeployRuleRequest deployRuleRequest = new DeployRuleRequest();\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
thrown.expect(WebApplicationException.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
expect(droolsEngine.deployRule(anyObject(DeployRuleRequest.class))).\r
andThrow(new CorrelationException(""));\r
PowerMock.replayAll();\r
- engineResources.deployRule(deployRuleRequest, httpRequest);\r
+ engineResources.deployRule(deployRuleRequest);\r
PowerMock.verifyAll();\r
}\r
\r
DeployRuleRequest deployRuleRequest = new DeployRuleRequest();\r
deployRuleRequest.setContent("package packageName;\n\nimport xxx.xxx.xxx;");\r
deployRuleRequest.setLoopControlName("loopControlName");\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
expect(droolsEngine.deployRule(anyObject(DeployRuleRequest.class))).andReturn("packageName");\r
PowerMock.replayAll();\r
- engineResources.deployRule(deployRuleRequest, httpRequest);\r
+ engineResources.deployRule(deployRuleRequest);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void undeployRule_exception() throws CorrelationException {\r
String packageName = "packageName";\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
thrown.expect(WebApplicationException.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.undeployRule(anyObject(String.class));\r
expectLastCall().andThrow(new CorrelationException(""));\r
PowerMock.replayAll();\r
- engineResources.undeployRule(packageName, httpRequest);\r
+ engineResources.undeployRule(packageName);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void undeployRule_normal() throws CorrelationException {\r
String packageName = "packageName";\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.undeployRule(anyObject(String.class));\r
PowerMock.replayAll();\r
- engineResources.undeployRule(packageName, httpRequest);\r
+ engineResources.undeployRule(packageName);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void compileRule_exception() throws CorrelationException {\r
CompileRuleRequest compileRuleRequest = new CompileRuleRequest();\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
thrown.expect(WebApplicationException.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.compileRule(anyObject(String.class));\r
expectLastCall().andThrow(new CorrelationException(""));\r
PowerMock.replayAll();\r
- engineResources.compileRule(compileRuleRequest, httpRequest);\r
+ engineResources.compileRule(compileRuleRequest);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void compileRule_normal() throws CorrelationException {\r
CompileRuleRequest compileRuleRequest = new CompileRuleRequest();\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
-\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.compileRule(anyObject(String.class));\r
PowerMock.replayAll();\r
- engineResources.compileRule(compileRuleRequest, httpRequest);\r
+ engineResources.compileRule(compileRuleRequest);\r
PowerMock.verifyAll();\r
}\r
}\r
/**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2021 ZTE Corporation.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
package org.onap.holmes.engine.wrapper;\r
\r
-import static org.easymock.EasyMock.anyInt;\r
-import static org.easymock.EasyMock.anyObject;\r
-import static org.easymock.EasyMock.expect;\r
-\r
-import java.util.ArrayList;\r
import org.junit.Before;\r
import org.junit.Rule;\r
import org.junit.Test;\r
import org.junit.rules.ExpectedException;\r
-import org.onap.holmes.common.api.entity.CorrelationRule;\r
import org.onap.holmes.common.exception.CorrelationException;\r
-import org.onap.holmes.common.utils.DbDaoUtil;\r
-import org.onap.holmes.engine.db.CorrelationRuleDao;\r
+import org.onap.holmes.engine.db.CorrelationRuleDaoService;\r
import org.powermock.api.easymock.PowerMock;\r
-import org.powermock.reflect.Whitebox;\r
+\r
+import java.util.ArrayList;\r
+\r
+import static org.easymock.EasyMock.anyInt;\r
+import static org.easymock.EasyMock.expect;\r
\r
public class RuleMgtWrapperTest {\r
\r
@Rule\r
public ExpectedException thrown = ExpectedException.none();\r
- private DbDaoUtil daoUtil;\r
+ private CorrelationRuleDaoService correlationRuleDaoService;\r
private RuleMgtWrapper ruleMgtWrapper;\r
\r
@Before\r
public void setUp() {\r
- daoUtil = PowerMock.createMock(DbDaoUtil.class);\r
- ruleMgtWrapper = new RuleMgtWrapper();\r
+ correlationRuleDaoService = PowerMock.createMock(CorrelationRuleDaoService.class);\r
+ ruleMgtWrapper = new RuleMgtWrapper(correlationRuleDaoService);\r
\r
- Whitebox.setInternalState(ruleMgtWrapper, "daoUtil", daoUtil);\r
PowerMock.resetAll();\r
}\r
\r
@Test\r
public void queryRuleByEnable_normal() throws CorrelationException {\r
int enable = 3;\r
-\r
- CorrelationRuleDao correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);\r
- expect(daoUtil.getJdbiDaoByOnDemand(anyObject(Class.class))).andReturn(correlationRuleDao);\r
- expect(correlationRuleDao.queryRuleByRuleEnable(anyInt())).andReturn(new ArrayList<CorrelationRule>());\r
+ expect(correlationRuleDaoService.queryRuleByRuleEnable(anyInt())).andReturn(new ArrayList());\r
PowerMock.replayAll();\r
ruleMgtWrapper.queryRuleByEnable(enable);\r
PowerMock.verifyAll();\r
<?xml version="1.0" encoding="UTF-8" ?>
<!--
- ~ Copyright 2017-2020 ZTE Corporation.
+ ~ Copyright 2017-2022 ZTE Corporation.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
<groupId>org.onap.holmes.engine-management</groupId>
<artifactId>holmes-engine-parent</artifactId>
- <version>1.3.7-SNAPSHOT</version>
+ <version>1.3.8-SNAPSHOT</version>
<packaging>pom</packaging>
<name>holmes-engine-management</name>
<modules>
<bundle.name>${project.artifactId}-${project.version}</bundle.name>
<drools.version>7.62.0.Final</drools.version>
- <dropwizard.version>2.0.9</dropwizard.version>
<powermock.version>2.0.7</powermock.version>
<jacoco.version>0.8.5</jacoco.version>
+ <springboot.version>2.7.2</springboot.version>
+ <jdbi.version>3.19.0</jdbi.version>
+ <jersey.version>3.0.5</jersey.version>
+ <jakarta.ws.rs.version>3.1.0</jakarta.ws.rs.version>
<packagename>onap-holmes-engine-d</packagename>
<linux64id>linux64</linux64id>
</sonar.coverage.jacoco.xmlReportPaths>
</properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${springboot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>org.postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>42.2.13</version>
- </dependency>
- <dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- <version>${dropwizard.version}</version>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
- <groupId>org.hibernate.validator</groupId>
- <artifactId>hibernate-validator</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>org.hibernate.validator</groupId>
- <artifactId>hibernate-validator</artifactId>
- <version>6.1.5.Final</version>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-autoconfigure</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-postgres</artifactId>
+ <version>${jdbi.version}</version>
</dependency>
<dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-db</artifactId>
- <version>${dropwizard.version}</version>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi3-sqlobject</artifactId>
+ <version>${jdbi.version}</version>
</dependency>
<dependency>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-jdbi</artifactId>
- <version>2.0.0-rc9</version>
+ <groupId>org.postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>42.2.13</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
- <version>1.18.4</version>
+ <version>1.18.16</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
- <dependency>
- <groupId>net.sf.json-lib</groupId>
- <artifactId>json-lib</artifactId>
- <version>2.4</version>
- <classifier>jdk15</classifier>
- <exclusions>
- <exclusion>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<dependency>
<groupId>org.onap.msb.java-sdk</groupId>
<artifactId>msb-java-sdk</artifactId>
<dependency>
<groupId>org.onap.holmes.common</groupId>
<artifactId>holmes-actions</artifactId>
- <version>1.4.2</version>
+ <version>1.4.3</version>
<exclusions>
- <exclusion>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-db</artifactId>
- </exclusion>
- <exclusion>
- <groupId>io.dropwizard</groupId>
- <artifactId>dropwizard-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.glassfish.jersey.containers</groupId>
- <artifactId>jersey-container-servlet-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.glassfish.hk2</groupId>
- <artifactId>hk2-locator</artifactId>
- </exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>jakarta.ws.rs</groupId>
+ <artifactId>jakarta.ws.rs-api</artifactId>
+ <version>${jakarta.ws.rs.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.xml.bind</groupId>
+ <artifactId>jakarta.xml.bind-api</artifactId>
+ <version>4.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.3.1</version>
+ </dependency>
+
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
- <groupId>org.drools</groupId>
- <artifactId>drools-mvel</artifactId>
- <version>${drools.version}</version>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>okhttp</artifactId>
+ <version>3.14.1</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
- <version>2.8.9</version>
- </dependency>
- <dependency>
- <groupId>com.squareup.retrofit2</groupId>
- <artifactId>retrofit</artifactId>
- <version>2.5.0</version>
+ <version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
- <version>1.4.18</version>
+ <version>1.4.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.inject</groupId>
+ <artifactId>jersey-hk2</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-json-jackson</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.containers</groupId>
+ <artifactId>jersey-container-servlet-core</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.ext</groupId>
+ <artifactId>jersey-entity-filtering</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.annotation</groupId>
+ <artifactId>jakarta.annotation-api</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ <scope>provided</scope>
</dependency>
<!-- Do NOT remove org.reflections:reflections. Otherwise, the docker will fail to start. -->
<artifactId>powermock-classloading-xstream</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>xstream</artifactId>
+ <groupId>com.thoughtworks.xstream</groupId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>2.28.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-support</artifactId>
+ <version>2.0.7</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
+ <version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.8.0</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- <release>11</release>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <version>${jacoco.version}</version>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>report</id>
- <goals>
- <goal>report</goal>
- </goals>
- <configuration>
- <dataFile>${project.build.directory}/code-coverage/jacoco.exec</dataFile>
- <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
</project>