summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main/java/org
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/main/java/org
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/main/java/org')
-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
2 files changed, 8 insertions, 2 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;
}