Replace outdated dependency - org.apache.commons:commons-jci-core:jar:1.1

Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: I5b34fff0600f1343a4ca9e00cf737946e3737214
Issue-ID: SDC-4569
diff --git a/asdctool/pom.xml b/asdctool/pom.xml
index d84a22a..3b7376d 100644
--- a/asdctool/pom.xml
+++ b/asdctool/pom.xml
@@ -207,20 +207,6 @@
       <scope>compile</scope>
     </dependency>
 
-    <!-- listen to file changes -->
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-jci-core</artifactId>
-      <version>${commons-jci-core.version}</version>
-      <scope>compile</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>commons-io</groupId>
-          <artifactId>commons-io</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-
     <dependency>
       <groupId>commons-cli</groupId>
       <artifactId>commons-cli</artifactId>
diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml
index 484544f..93e7025 100644
--- a/catalog-be/pom.xml
+++ b/catalog-be/pom.xml
@@ -252,20 +252,6 @@
             <scope>compile</scope>
         </dependency>
 
-        <!-- File changes listener -->
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-jci-core</artifactId>
-            <version>${commons-jci-core.version}</version>
-            <scope>compile</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>commons-io</groupId>
-                    <artifactId>commons-io</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
         <!-- Gson -->
         <dependency>
             <groupId>com.google.code.gson</groupId>
diff --git a/catalog-dao/pom.xml b/catalog-dao/pom.xml
index c145b68..8061800 100644
--- a/catalog-dao/pom.xml
+++ b/catalog-dao/pom.xml
@@ -300,19 +300,6 @@
     </dependency>
 
     <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-jci-core</artifactId>
-      <version>${commons-jci-core.version}</version>
-      <scope>test</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>commons-io</groupId>
-          <artifactId>commons-io</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-
-    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-expression</artifactId>
       <version>${spring.version}</version>
diff --git a/catalog-fe/pom.xml b/catalog-fe/pom.xml
index d1d1404..1e3009a 100644
--- a/catalog-fe/pom.xml
+++ b/catalog-fe/pom.xml
@@ -97,19 +97,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-jci-core</artifactId>
-            <version>${commons-jci-core.version}</version>
-            <scope>compile</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>commons-io</groupId>
-                    <artifactId>commons-io</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
-        <dependency>
             <groupId>com.google.code.gson</groupId>
             <artifactId>gson</artifactId>
             <version>${gson.version}</version>
diff --git a/catalog-model/pom.xml b/catalog-model/pom.xml
index 5a30598..f8e2ef7 100644
--- a/catalog-model/pom.xml
+++ b/catalog-model/pom.xml
@@ -450,19 +450,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-jci-core</artifactId>
-            <version>${commons-jci-core.version}</version>
-            <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>commons-io</groupId>
-                    <artifactId>commons-io</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
-        <dependency>
             <groupId>org.awaitility</groupId>
             <artifactId>awaitility</artifactId>
             <version>${awaitility.version}</version>
diff --git a/common-app-api/pom.xml b/common-app-api/pom.xml
index eb61d72..cb28cb0 100644
--- a/common-app-api/pom.xml
+++ b/common-app-api/pom.xml
@@ -110,20 +110,6 @@
             <scope>provided</scope>
         </dependency>
 
-        <!-- listen to file changes -->
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-jci-core</artifactId>
-            <version>${commons-jci-core.version}</version>
-            <scope>provided</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>commons-io</groupId>
-                    <artifactId>commons-io</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-
         <!-- Gson -->
         <dependency>
             <groupId>com.google.code.gson</groupId>
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
index 4efc43d..ca923b5 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
@@ -25,7 +25,7 @@
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.jci.listeners.FileChangeListener;
+import org.apache.commons.io.monitor.FileAlterationListenerAdaptor;
 import org.openecomp.sdc.common.api.BasicConfiguration;
 import org.openecomp.sdc.common.api.ConfigurationListener;
 import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
@@ -33,7 +33,8 @@
 import org.openecomp.sdc.common.util.YamlToObjectConverter;
 import org.openecomp.sdc.exception.YamlConversionException;
 
-public class ConfigFileChangeListener extends FileChangeListener {
+
+public class ConfigFileChangeListener extends FileAlterationListenerAdaptor {
 
     private static final Logger LOGGER = Logger.getLogger(ConfigFileChangeListener.class.getName());
     private Map<String, List<ConfigurationListener>> fileChangeToCallBack = new HashMap<>();
@@ -42,7 +43,6 @@
 
     @Override
     public void onFileChange(File pFile) {
-        super.onFileChange(pFile);
         if (pFile == null) {
             LOGGER.debug("Invalid file '{}'.", pFile);
             return;
@@ -68,7 +68,7 @@
                 basicConfiguration = yamlToObjectConverter.convert(pFile.getAbsolutePath(), configClass);
             } catch (final YamlConversionException e) {
                 LOGGER.warn(EcompLoggerErrorCode.SCHEMA_ERROR, "Configuration", "Configuration",
-                    "Cannot update the listeners for file Change since the file content is invalid: {}", e.getLocalizedMessage());
+                        "Cannot update the listeners for file Change since the file content is invalid: {}", e.getLocalizedMessage());
                 continue;
             }
             LOGGER.debug("Loaded configuration after converting is {}", basicConfiguration);
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java
index 7c665c6..def72b7 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java
@@ -20,9 +20,11 @@
 package org.openecomp.sdc.common.impl;
 
 import java.io.File;
-import org.apache.commons.jci.monitor.FilesystemAlterationMonitor;
+import org.apache.commons.io.monitor.FileAlterationMonitor;
+import org.apache.commons.io.monitor.FileAlterationObserver;
 import org.openecomp.sdc.common.api.ConfigurationSource;
 
+
 /**
  * Save the
  *
@@ -34,7 +36,7 @@
     private static String appVersion;
     private static String configDir;
     private static ConfigurationSource configurationSource;
-    private static FilesystemAlterationMonitor fam = null;
+    private static FileAlterationMonitor monitor;
     private static ConfigFileChangeListener changeListener = new ConfigFileChangeListener();
     private static boolean enableReconfigure = true;
 
@@ -75,23 +77,28 @@
     }
 
     public static void listenForChanges() {
-        String watchingDir = configDir + File.separator + appName;
         if (enableReconfigure) {
-            if (fam == null) {
-                fam = new FilesystemAlterationMonitor();
-                fam.setInterval(1000);
-                fam.addListener(new File(watchingDir), changeListener);
-                fam.start();
+            monitor = new FileAlterationMonitor();
+            final String watchingDir = configDir + File.separator + appName;
+            final FileAlterationObserver observer = new FileAlterationObserver(watchingDir);
+            observer.addListener(changeListener);
+            monitor.addObserver(observer);
+            try {
+                monitor.start();
+            } catch (final Exception e) {
+                throw new RuntimeException(e);
             }
         }
     }
 
     public static void stopListenForFileChanges() {
-        if (enableReconfigure) {
-            if (fam != null) {
-                fam.stop();
-                fam = null;
+        if (enableReconfigure && monitor != null) {
+            try {
+                monitor.stop();
+            } catch (Exception e) {
+                throw new RuntimeException(e);
             }
+            monitor = null;
         }
     }
 }
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java
index 70a94fd..a4e6156 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java
@@ -39,6 +39,7 @@
 
     private static Logger log = Logger.getLogger(AppContextListener.class.getName());
 
+    @Override
     public void contextInitialized(ServletContextEvent context) {
         log.debug("ServletContextListener initialized ");
         log.debug("After read values from Manifest {}", getManifestInfo(context.getServletContext()));
@@ -50,13 +51,13 @@
         String configHome = System.getProperty(Constants.CONFIG_HOME);
         ExternalConfiguration.setConfigDir(configHome);
         String appConfigDir = configHome + File.separator + appName;
-        // ChangeListener changeListener = new ChangeListener();
         ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
         context.getServletContext().setAttribute(Constants.CONFIGURATION_SOURCE_ATTR, configurationSource);
         ExternalConfiguration.setConfigurationSource(configurationSource);
         ExternalConfiguration.listenForChanges();
     }
 
+    @Override
     public void contextDestroyed(ServletContextEvent context) {
         log.debug("ServletContextListener destroyed");
         ExternalConfiguration.stopListenForFileChanges();
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
index 0d5cf62..38d1e65 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
@@ -102,26 +102,5 @@
     }
 
     public void reconfigure(BasicConfiguration obj) {
-        //
-
-        // if (obj != null) {
-
-        //
-
-        // if (obj instanceof Configuration) {
-
-        // configurations.put(getKey(Configuration.class), obj);
-
-        // }
-
-        //
-
-        // if (obj instanceof EcompErrorConfiguration) {
-
-        // configurations.put(getKey(EcompErrorConfiguration.class), obj);
-
-        // }
-
-        // }
     }
 }
diff --git a/pom.xml b/pom.xml
index 185858a..c80fec4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -127,9 +127,6 @@
         <!--GSON-->
         <gson.version>2.10.1</gson.version>
 
-        <!--listen to file changes-->
-        <commons-jci-core.version>1.1</commons-jci-core.version>
-
         <!--TESTING-->
         <mockito.version>4.10.0</mockito.version>
         <mockitoJupiter.version>${mockito.version}</mockitoJupiter.version>