Add DEBUG logging to ConfigurationAdmin and Configuration API method implementations

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1197497 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
index eae4dfb..f005194 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdapter.java
@@ -23,6 +23,7 @@
 import java.util.Dictionary;
 
 import org.osgi.service.cm.Configuration;
+import org.osgi.service.log.LogService;
 
 
 /**
@@ -70,6 +71,8 @@
      */
     public String getBundleLocation()
     {
+        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getBundleLocation()", ( Throwable ) null );
+
         // CM 1.4 / 104.13.2.4
         configurationAdmin.checkPermission( delegatee.getBundleLocation() );
         checkDeleted();
@@ -83,6 +86,10 @@
      */
     public void setBundleLocation( String bundleLocation )
     {
+        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "setBundleLocation(bundleLocation={0})",
+            new Object[]
+                { bundleLocation } );
+
         // CM 1.4 / 104.13.2.4
         configurationAdmin.checkPermission( delegatee.getBundleLocation() );
         configurationAdmin.checkPermission( ( bundleLocation == null ) ? "*" : bundleLocation );
@@ -97,6 +104,8 @@
      */
     public void update() throws IOException
     {
+        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "update()", ( Throwable ) null );
+
         checkDeleted();
         delegatee.update();
     }
@@ -109,6 +118,9 @@
      */
     public void update( Dictionary properties ) throws IOException
     {
+        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "update(properties={0})", new Object[]
+            { properties } );
+
         checkDeleted();
         delegatee.update( properties );
     }
@@ -119,6 +131,8 @@
      */
     public Dictionary getProperties()
     {
+        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "getProperties()", ( Throwable ) null );
+
         checkDeleted();
 
         // return a deep copy since the spec says, that modification of
@@ -133,6 +147,8 @@
      */
     public void delete() throws IOException
     {
+        delegatee.getConfigurationManager().log( LogService.LOG_DEBUG, "delete()", ( Throwable ) null );
+
         checkDeleted();
         delegatee.delete();
     }
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
index 6f40898..63babbe 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationAdminImpl.java
@@ -71,6 +71,9 @@
      */
     public Configuration createFactoryConfiguration( String factoryPid ) throws IOException
     {
+        configurationManager.log( LogService.LOG_DEBUG, "createFactoryConfiguration(factoryPid={0})", new Object[]
+            { factoryPid } );
+
         return this.wrap( configurationManager.createFactoryConfiguration( this, factoryPid ) );
     }
 
@@ -80,6 +83,10 @@
      */
     public Configuration createFactoryConfiguration( String factoryPid, String location ) throws IOException
     {
+        configurationManager.log( LogService.LOG_DEBUG, "createFactoryConfiguration(factoryPid={0}, location={1})",
+            new Object[]
+                { factoryPid, location } );
+
         // CM 1.4 / 104.13.2.3
         this.checkPermission( location );
 
@@ -92,6 +99,9 @@
      */
     public Configuration getConfiguration( String pid ) throws IOException
     {
+        configurationManager.log( LogService.LOG_DEBUG, "getConfiguration(pid={0})", new Object[]
+            { pid } );
+
         ConfigurationImpl config = configurationManager.getConfiguration( pid, getBundle().getLocation() );
 
         if ( config.getBundleLocation() == null )
@@ -117,6 +127,9 @@
      */
     public Configuration getConfiguration( String pid, String location ) throws IOException
     {
+        configurationManager.log( LogService.LOG_DEBUG, "getConfiguration(pid={0}, location={1})", new Object[]
+            { pid, location } );
+
         // CM 1.4 / 104.13.2.3
         this.checkPermission( location );
 
@@ -136,6 +149,9 @@
      */
     public Configuration[] listConfigurations( String filter ) throws IOException, InvalidSyntaxException
     {
+        configurationManager.log( LogService.LOG_DEBUG, "listConfigurations(filter={0})", new Object[]
+            { filter } );
+
         ConfigurationImpl ci[] = configurationManager.listConfigurations( this, filter );
         if ( ci == null || ci.length == 0 )
         {
@@ -199,15 +215,25 @@
             // CM 1.4 / 104.11.1 Implicit permission
             if ( name != null && !name.equals( getBundle().getLocation() ) )
             {
-                sm.checkPermission( new ConfigurationPermission( name, ConfigurationPermission.CONFIGURE ) );
-
-                if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
+                try
                 {
+                    sm.checkPermission( new ConfigurationPermission( name, ConfigurationPermission.CONFIGURE ) );
+
                     configurationManager.log( LogService.LOG_DEBUG,
                         "Explicit Permission; grant CONFIGURE permission on configuration bound to {0} to bundle {1}",
                         new Object[]
                             { name, getBundle().getLocation() } );
                 }
+                catch ( SecurityException se )
+                {
+                    configurationManager
+                        .log(
+                            LogService.LOG_DEBUG,
+                            "No Permission; denied CONFIGURE permission on configuration bound to {0} to bundle {1}; reason: {2}",
+                            new Object[]
+                                { name, getBundle().getLocation(), se.getMessage() } );
+                    throw se;
+                }
             }
             else if ( configurationManager.isLogEnabled( LogService.LOG_DEBUG ) )
             {