summaryrefslogtreecommitdiffstats
path: root/rulemgt/src
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2022-08-15 18:26:04 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2022-08-15 18:26:04 +0800
commit4627750077003db93420c053faa66310b27af7b1 (patch)
treebc9e5da1fc966dbd1d97aec69bce7e45e438d81f /rulemgt/src
parent1741310e9bae9c4ab70bdb34b0bfb54d0389c9b1 (diff)
bugfix - accidental removal of rules
Issue-ID: HOLMES-564 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn> Change-Id: Ifda11ebea31a5269e59d7fe6ee65a74da979497b
Diffstat (limited to 'rulemgt/src')
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleCreateRequest.java4
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java6
-rw-r--r--rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java3
3 files changed, 10 insertions, 3 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleCreateRequest.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleCreateRequest.java
index 8dc98d8..f08ec9b 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleCreateRequest.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleCreateRequest.java
@@ -1,5 +1,5 @@
/**
- * 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.
@@ -30,5 +30,7 @@ public class RuleCreateRequest {
private String content;
+ private String creator;
+
private int enabled;
}
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java
index fc042ad..ee8d4f9 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java
@@ -36,11 +36,13 @@ import jakarta.ws.rs.core.MediaType;
import java.io.File;
import java.nio.file.Paths;
import java.util.*;
+import java.util.stream.Collectors;
public class ConfigFileScanningTask implements Runnable {
final public static long POLLING_PERIOD = 30L;
final private static Logger LOGGER = LoggerFactory.getLogger(ConfigFileScanningTask.class);
final private static long FILE_SIZE_LMT = 1024 * 1024 * 10; // 10MB
+ final private static String CREATOR = "__SYSTEM__DEFAULT__";
private String configFile = "/opt/hrmrules/index.json";
private ConfigFileScanner configFileScanner;
private String url;
@@ -175,7 +177,8 @@ public class ConfigFileScanningTask implements Runnable {
RuleQueryListResponse ruleQueryListResponse = JerseyClient.newInstance().get(url, RuleQueryListResponse.class);
List<RuleResult4API> deployedRules = Collections.EMPTY_LIST;
if (null != ruleQueryListResponse) {
- deployedRules = ruleQueryListResponse.getCorrelationRules();
+ deployedRules = ruleQueryListResponse.getCorrelationRules()
+ .stream().filter(r -> CREATOR.equals(r.getCreator())).collect(Collectors.toList());
}
return deployedRules;
}
@@ -197,6 +200,7 @@ public class ConfigFileScanningTask implements Runnable {
ruleCreateRequest.setContent(contents);
ruleCreateRequest.setDescription("");
ruleCreateRequest.setEnabled(1);
+ ruleCreateRequest.setCreator(CREATOR);
return ruleCreateRequest;
}
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java
index 396c2c1..a4ab15b 100644
--- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java
+++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2021 ZTE Corporation.
+ * 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.
@@ -214,6 +214,7 @@ public class ConfigFileScanningTaskTest {
ruleResult4API.setContent(contents);
ruleResult4API.setDescription("");
ruleResult4API.setEnabled(1);
+ ruleResult4API.setCreator("__SYSTEM__DEFAULT__");
return ruleResult4API;
}
} \ No newline at end of file