felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1790564 - /felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
Date Fri, 07 Apr 2017 14:35:24 GMT
Author: gnodet
Date: Fri Apr  7 14:35:24 2017
New Revision: 1790564

URL: http://svn.apache.org/viewvc?rev=1790564&view=rev
Log:
[FELIX-5610] Files should be deleted if a configuration is deleted

Modified:
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java?rev=1790564&r1=1790563&r2=1790564&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
Fri Apr  7 14:35:24 2017
@@ -169,6 +169,27 @@ public class ConfigInstaller implements
                 Util.log( context, Logger.LOG_INFO, "Unable to save configuration", e );
             }
         }
+
+        if (configurationEvent.getType() == ConfigurationEvent.CM_DELETED)
+        {
+            try {
+                Configuration config = getConfigurationAdmin().getConfiguration(
+                        configurationEvent.getPid(),
+                        configurationEvent.getFactoryPid());
+                Dictionary dict = config.getProperties();
+                String fileName = (String) dict.get(DirectoryWatcher.FILENAME);
+                File file = fileName != null ? fromConfigKey(fileName) : null;
+                if (file != null && file.isFile()) {
+                    if (!file.delete()) {
+                        throw new IOException("Unable to delete file: " + file);
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                Util.log( context, Logger.LOG_INFO, "Unable to delete configuration file",
e );
+            }
+        }
     }
 
     boolean shouldSaveConfig()



Mime
View raw message