You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2021/08/29 08:41:38 UTC

[felix-dev] branch master updated: FELIX-6453 : Change in configuration handling introduces by FELIX-6436

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new f8dd428  FELIX-6453 : Change in configuration handling introduces by FELIX-6436
f8dd428 is described below

commit f8dd428a2bd5aeef3aab841eefde9add6f51e782
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Aug 29 10:41:29 2021 +0200

    FELIX-6453 : Change in configuration handling introduces by FELIX-6436
---
 .../internal/configuration/ConfigAdminSupport.java | 47 +++++++++-------------
 .../internal/configuration/ConfigManager.java      | 21 ++++------
 2 files changed, 26 insertions(+), 42 deletions(-)

diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
index e7b7aad..33dab7a 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
@@ -131,10 +131,9 @@ class ConfigAdminSupport {
      * @param pid The pid 
      * @param propertyList The list of properties
      * @param isUpdate {@code true} if this is a rest call, false if it is done via the webconsole UI
-     * @return {@code true} when the configuration got updated, {@code false} when the codnfiugration got deleted
      * @throws IOException
      */
-    boolean applyConfiguration( final HttpServletRequest request, final String pid, final String propertyList, final boolean isUpdate )
+    void applyConfiguration( final HttpServletRequest request, final String pid, final String propertyList, final boolean isUpdate )
             throws IOException
     {
         final String factoryPid = request.getParameter( ConfigManager.FACTORY_PID );
@@ -316,39 +315,31 @@ class ConfigAdminSupport {
             h.updateConfiguration(factoryPid, pid, props);
         }
   
-        if ( props.isEmpty() ) {
-            this.deleteConfiguration(config);
-
-            return false;
-        } else {
-            final String location = request.getParameter(ConfigManager.LOCATION);
-            if ( location == null || location.trim().length() == 0 || ConfigManager.UNBOUND_LOCATION.equals(location) )
+        final String location = request.getParameter(ConfigManager.LOCATION);
+        if ( location == null || location.trim().length() == 0 || ConfigManager.UNBOUND_LOCATION.equals(location) )
+        {
+            if ( config.getBundleLocation() != null )
             {
+                config.setBundleLocation(null);
+                // workaround for Felix Config Admin 1.2.8 not clearing dynamic
+                // bundle location when clearing static bundle location. In
+                // this case we first set the static bundle location to the
+                // dynamic bundle location and then try to set both to null
                 if ( config.getBundleLocation() != null )
                 {
-                    config.setBundleLocation(null);
-                    // workaround for Felix Config Admin 1.2.8 not clearing dynamic
-                    // bundle location when clearing static bundle location. In
-                    // this case we first set the static bundle location to the
-                    // dynamic bundle location and then try to set both to null
-                    if ( config.getBundleLocation() != null )
-                    {
-                        config.setBundleLocation( "??invalid:bundle/location" ); //$NON-NLS-1$
-                        config.setBundleLocation( null );
-                    }
+                    config.setBundleLocation( "??invalid:bundle/location" ); //$NON-NLS-1$
+                    config.setBundleLocation( null );
                 }
-            } 
-            else
+            }
+        } 
+        else
+        {
+            if ( config.getBundleLocation() == null || !config.getBundleLocation().equals(location) )
             {
-                if ( config.getBundleLocation() == null || !config.getBundleLocation().equals(location) )
-                {
-                    config.setBundleLocation(location);
-                }
+                config.setBundleLocation(location);
             }
-            config.update( props );
-    
-            return true;
         }
+        config.update( props );
     }
 
     public void deleteConfiguration(final String pid) throws IOException {
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
index 48a0f6e..2e5baf0 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigManager.java
@@ -159,25 +159,18 @@ public class ConfigManager extends SimpleWebConsolePlugin implements OsgiManager
             else 
             {
                 final String propertyList = request.getParameter( ConfigManager.PROPERTY_LIST ); //$NON-NLS-1$
-                if ( propertyList == null )
-                {
+                if ( propertyList == null ) {
                     response.sendError(400);
                     return;        
                 }
 
-                if (cas.applyConfiguration( request, pid, propertyList, ACTION_UPDATE.equals(request.getParameter(ACTION_APPLY)) ) )
-                {
-                    String redirect = pid;
-                    if (pidFilter != null) {
-                        redirect += '?' + PID_FILTER + '=' + pidFilter;
-                    }
-    
-                    WebConsoleUtil.sendRedirect(request, response, redirect);    
-                }
-                else
-                {
-                    Util.sendJsonOk(response);
+                cas.applyConfiguration( request, pid, propertyList, ACTION_UPDATE.equals(request.getParameter(ACTION_APPLY)));
+                String redirect = pid;
+                if (pidFilter != null) {
+                    redirect = redirect.concat("?").concat(PID_FILTER).concat("=").concat(pidFilter);
                 }
+    
+                WebConsoleUtil.sendRedirect(request, response, redirect);    
             }
             
             return;