Resolved FELIX-1996 /Console should warn when config is bound to a different bundle/
https://issues.apache.org/jira/browse/FELIX-1996

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@926009 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
index f28fc1d..5129242 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
@@ -790,6 +790,28 @@
         }
         json.key( "bundleLocation" );
         json.value( location );
+        // raw bundle location and service locations
+        final String pid = config.getPid();
+        String serviceLocation = "";
+        try
+        {
+            final ServiceReference[] refs = getBundleContext().getServiceReferences(
+                null,
+                "(&(" + Constants.OBJECTCLASS + '=' + ManagedService.class.getName()
+                    + ")(" + Constants.SERVICE_PID + '=' + pid + "))");
+            if ( refs != null && refs.length > 0 )
+            {
+                serviceLocation = refs[0].getBundle().getLocation();
+            }
+        }
+        catch (Throwable t)
+        {
+            log( "Error getting service associated with configuration " + pid, t );
+        }
+        json.key( "bundle_location" );
+        json.value ( config.getBundleLocation() );
+        json.key( "service_location" );
+        json.value ( serviceLocation );
     }
 
 
diff --git a/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties b/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
index 91adb01..ef10386 100644
--- a/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
+++ b/webconsole/src/main/native2ascii/OSGI-INF/l10n/bundle_bg.properties
@@ -201,6 +201,7 @@
 config.title.actions=Действия
 config.title.bundle=Бъндъл
 config.title.name=Име
+config.bind.error=Грешка: PID "{0}" е асоцииран с "{1}" но улугата е регистриране от бъндъл "{2}"
 
 # License plugin
 license.pluginTitle=Лицензи
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
index 8c05008..3ff8e9b 100644
--- a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -201,6 +201,7 @@
 config.title.actions=Actions
 config.title.bundle=Bundle
 config.title.name=Name
+config.bind.error=Error: the PID "{0}" is bound to "{1}" but the actual managed service is registered from "{2}" bundle
 
 # License plugin
 license.pluginTitle=Licenses
diff --git a/webconsole/src/main/resources/res/ui/config.js b/webconsole/src/main/resources/res/ui/config.js
index 6eeeb2b..11061ce 100644
--- a/webconsole/src/main/resources/res/ui/config.js
+++ b/webconsole/src/main/resources/res/ui/config.js
@@ -29,6 +29,7 @@
 
 // editor dialog
 var editor = false;
+var editorMessage = false;
 
 function configure(pid, create) {
 	var uri = pluginRoot + '/' + pid;
@@ -116,6 +117,9 @@
     }
 
     printConfigurationInfo(parent, obj);
+	if ( obj.service_location && obj.bundle_location && obj.service_location != obj.bundle_location) {
+		editorMessage.removeClass('ui-helper-hidden').text(i18n.err_bind.msgFormat(obj.pid, obj.bundle_location, obj.service_location));
+	} else editorMessage.addClass('ui-helper-hidden');
 	initStaticWidgets(editor.attr('__pid', obj.pid).dialog('option', 'title', obj.title).dialog('open'));
 }
 
@@ -521,6 +525,7 @@
 		closeText: i18n.abort,
 		buttons  : _buttons
 	});
+	editorMessage = editor.find('p');
 
 	// display the configuration data
 	$(".statline").html(configData.status ? i18n.stat_ok : i18n.stat_missing);
diff --git a/webconsole/src/main/resources/templates/config.html b/webconsole/src/main/resources/templates/config.html
index a013e33..1e60387 100644
--- a/webconsole/src/main/resources/templates/config.html
+++ b/webconsole/src/main/resources/templates/config.html
@@ -23,7 +23,8 @@
 	del_ask      : '${config.del.ask}', // "Are you sure to delete this configuration ?";
 	del_config   : '${config.del.config}', // "Configuration: ";
 	del_bundle   : '${config.del.bundle}', // "Bundle: ";
-	unbind_ask   : '${config.unbind.ask}' // "Are you sure to unbind this configuration ?"
+	unbind_ask   : '${config.unbind.ask}', // "Are you sure to unbind this configuration ?"
+	err_bind     : '${config.bind.error}' // Error: the PID'{0}' is bound to '{1}' but the actual managed service is registered from '{2}' bundle
 }
 // ]]>
 </script>
@@ -72,6 +73,7 @@
 
 <!-- placeholder for property editor -->
 <div id="editor" class="ui-helper-hidden">
+	<p class="ui-state-error ui-helper-hidden">&nbsp;</p>
 	<table id="editorTable" class="nicetable">
 		<tr><td>&nbsp;</td></tr>
 	</table>