Replace outdated dependency - org.apache.commons:commons-jci-core:jar:1.1 14/135414/2
authorvasraz <vasyl.razinkov@est.tech>
Thu, 13 Jul 2023 12:59:35 +0000 (13:59 +0100)
committerMichael Morris <michael.morris@est.tech>
Thu, 13 Jul 2023 15:01:24 +0000 (15:01 +0000)
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: I5b34fff0600f1343a4ca9e00cf737946e3737214
Issue-ID: SDC-4569

asdctool/pom.xml
catalog-be/pom.xml
catalog-dao/pom.xml
catalog-fe/pom.xml
catalog-model/pom.xml
common-app-api/pom.xml
common-app-api/src/main/java/org/openecomp/sdc/common/impl/ConfigFileChangeListener.java
common-app-api/src/main/java/org/openecomp/sdc/common/impl/ExternalConfiguration.java
common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java
common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
pom.xml

index d84a22a..3b7376d 100644 (file)
       <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>
index 484544f..93e7025 100644 (file)
             <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>
index c145b68..8061800 100644 (file)
@@ -299,19 +299,6 @@ Modifications copyright (c) 2018 Nokia
       <scope>test</scope>
     </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>
index d1d1404..1e3009a 100644 (file)
             <scope>compile</scope>
         </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>
index 5a30598..f8e2ef7 100644 (file)
             <version>${spring.version}</version>
         </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>
index eb61d72..cb28cb0 100644 (file)
             <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>
index 4efc43d..ca923b5 100644 (file)
@@ -25,7 +25,7 @@ import java.util.HashMap;
 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.log.wrappers.Logger;
 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 @@ public class ConfigFileChangeListener extends FileChangeListener {
 
     @Override
     public void onFileChange(File pFile) {
-        super.onFileChange(pFile);
         if (pFile == null) {
             LOGGER.debug("Invalid file '{}'.", pFile);
             return;
@@ -68,7 +68,7 @@ public class ConfigFileChangeListener extends FileChangeListener {
                 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);
index 7c665c6..def72b7 100644 (file)
 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 @@ public class ExternalConfiguration {
     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 class ExternalConfiguration {
     }
 
     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;
         }
     }
 }
index 70a94fd..a4e6156 100644 (file)
@@ -39,6 +39,7 @@ public class AppContextListener implements ServletContextListener {
 
     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 @@ public class AppContextListener implements ServletContextListener {
         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();
index 0d5cf62..38d1e65 100644 (file)
@@ -102,26 +102,5 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura
     }
 
     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 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -127,9 +127,6 @@ Modifications copyright (c) 2018-2019 Nokia
         <!--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>