bugfix - accidental removal of rules 80/130280/1
authorGuangrong Fu <fu.guangrong@zte.com.cn>
Mon, 15 Aug 2022 10:26:04 +0000 (18:26 +0800)
committerGuangrong Fu <fu.guangrong@zte.com.cn>
Mon, 15 Aug 2022 10:26:04 +0000 (18:26 +0800)
Issue-ID: HOLMES-564
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Change-Id: Ifda11ebea31a5269e59d7fe6ee65a74da979497b

rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleCreateRequest.java
rulemgt/src/main/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTask.java
rulemgt/src/test/java/org/onap/holmes/rulemgt/dcae/ConfigFileScanningTaskTest.java

index 8dc98d8..f08ec9b 100644 (file)
@@ -1,5 +1,5 @@
 /**\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
@@ -30,5 +30,7 @@ public class RuleCreateRequest {
 \r
     private String content;\r
 \r
+    private String creator;\r
+\r
     private int enabled;\r
 }\r
index fc042ad..ee8d4f9 100644 (file)
@@ -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;
     }
 
index 396c2c1..a4ab15b 100644 (file)
@@ -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