Consolidate "update" flag setting with configuraiton property
update setting

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@805305 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
index 9e11d81..353a838 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationImpl.java
@@ -352,9 +352,6 @@
 
             configureFromPersistence( properties );
 
-            // ensure configuration is being delivered
-            setDelivered( false );
-
             configurationManager.updated( this );
         }
     }
@@ -372,10 +369,9 @@
 
             setAutoProperties( newProperties, staticallyBound );
 
+            // persist new configuration
             localPersistenceManager.store( pid, newProperties );
 
-            configure( newProperties );
-
             // if this is a factory configuration, update the factory with
             String factoryPid = getFactoryPid();
             if ( factoryPid != null )
@@ -385,12 +381,20 @@
                 {
                     // only write back if the pid was not already registered
                     // with the factory
-                    factory.store();
+                    try
+                    {
+                        factory.store();
+                    }
+                    catch ( IOException ioe )
+                    {
+                        configurationManager.log( LogService.LOG_ERROR, "Failure storing factory " + factoryPid
+                            + " with new configuration " + pid, ioe );
+                    }
                 }
             }
 
-            // ensure configuration is being delivered
-            setDelivered( false );
+            // finally assign the configuration for use
+            configure( newProperties );
 
             configurationManager.updated( this );
         }
@@ -485,8 +489,7 @@
      */
     boolean isDeleted()
     {
-        PersistenceManager persistenceManager = getPersistenceManager();
-        return persistenceManager == null;
+        return getPersistenceManager() == null;
     }
 
 
@@ -523,23 +526,36 @@
         }
         else
         {
-            this.properties = null;
+            configure( null );
         }
     }
 
-    private void configure( Dictionary properties )
+    private void configure( final Dictionary properties )
     {
-        // remove predefined properties
-        clearAutoProperties( properties );
-
-        // ensure CaseInsensitiveDictionary
-        if ( properties instanceof CaseInsensitiveDictionary )
+        final CaseInsensitiveDictionary newProperties;
+        if ( properties == null )
         {
-            this.properties = ( CaseInsensitiveDictionary ) properties;
+            newProperties = null;
         }
         else
         {
-            this.properties = new CaseInsensitiveDictionary( properties );
+            // remove predefined properties
+            clearAutoProperties( properties );
+
+            // ensure CaseInsensitiveDictionary
+            if ( properties instanceof CaseInsensitiveDictionary )
+            {
+                newProperties = ( CaseInsensitiveDictionary ) properties;
+            }
+            else
+            {
+                newProperties = new CaseInsensitiveDictionary( properties );
+            }
+        }
+
+        synchronized (this) {
+            this.properties = newProperties;
+            this.setDelivered( false );
         }
     }