FELIX-4564 : JSON Output overwrites resource information
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1611236 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/obr/pom.xml b/webconsole-plugins/obr/pom.xml
index 70dfb5f..1fce18e 100644
--- a/webconsole-plugins/obr/pom.xml
+++ b/webconsole-plugins/obr/pom.xml
@@ -101,7 +101,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>4.0.0</version>
+ <version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -134,7 +134,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.bundlerepository</artifactId>
- <version>1.6.0</version>
+ <version>2.0.2</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
diff --git a/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/FelixBundleRepositoryRenderHelper.java b/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/FelixBundleRepositoryRenderHelper.java
index 9858577..2bddb28 100644
--- a/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/FelixBundleRepositoryRenderHelper.java
+++ b/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/FelixBundleRepositoryRenderHelper.java
@@ -20,7 +20,9 @@
import java.io.IOException;
+
import javax.servlet.ServletException;
+
import org.apache.felix.bundlerepository.Capability;
import org.apache.felix.bundlerepository.Property;
import org.apache.felix.bundlerepository.Reason;
@@ -34,8 +36,8 @@
import org.json.JSONObject;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.Version;
/**
@@ -203,14 +205,17 @@
private final JSONObject toJSON( Resource resource, Bundle[] bundles, boolean details ) throws JSONException
{
final String symbolicName = resource.getSymbolicName();
- final String version = resource.getVersion().toString();
- boolean installed = false;
- for ( int i = 0; symbolicName != null && !installed && bundles != null && i < bundles.length; i++ )
+ final Version version = resource.getVersion();
+ String installed = "";
+ for ( int i = 0; symbolicName != null && installed.length() == 0 && bundles != null && i < bundles.length; i++ )
{
- final String ver = ( String ) bundles[i].getHeaders( "" ).get( Constants.BUNDLE_VERSION ); //$NON-NLS-1$
- installed = symbolicName.equals( bundles[i].getSymbolicName() ) && version.equals( ver );
+ final Version ver = bundles[i].getVersion();
+ if ( symbolicName.equals(bundles[i].getSymbolicName()))
+ {
+ installed = ver.toString();
+ }
}
- JSONObject json = new JSONObject( resource.getProperties() ) //
+ JSONObject json = new JSONObject()
.put( "id", resource.getId() ) // //$NON-NLS-1$
.put( "presentationname", resource.getPresentationName() ) // //$NON-NLS-1$
.put( "symbolicname", symbolicName ) // //$NON-NLS-1$
diff --git a/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/OsgiBundleRepositoryRenderHelper.java b/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/OsgiBundleRepositoryRenderHelper.java
index fb22b5b..5f2a4a1 100644
--- a/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/OsgiBundleRepositoryRenderHelper.java
+++ b/webconsole-plugins/obr/src/main/java/org/apache/felix/webconsole/plugins/obr/internal/OsgiBundleRepositoryRenderHelper.java
@@ -21,13 +21,15 @@
import java.io.IOException;
import java.net.URL;
+
import javax.servlet.ServletException;
+
import org.apache.felix.webconsole.AbstractWebConsolePlugin;
import org.json.JSONException;
import org.json.JSONObject;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
import org.osgi.service.obr.Capability;
import org.osgi.service.obr.Repository;
import org.osgi.service.obr.RepositoryAdmin;
@@ -193,14 +195,17 @@
private final JSONObject toJSON( Resource resource, Bundle[] bundles, boolean details ) throws JSONException
{
final String symbolicName = resource.getSymbolicName();
- final String version = resource.getVersion().toString();
- boolean installed = false;
- for ( int i = 0; symbolicName != null && !installed && bundles != null && i < bundles.length; i++ )
+ final Version version = resource.getVersion();
+ String installed = "";
+ for ( int i = 0; symbolicName != null && installed.length() == 0 && bundles != null && i < bundles.length; i++ )
{
- final String ver = ( String ) bundles[i].getHeaders( "" ).get( Constants.BUNDLE_VERSION ); //$NON-NLS-1$
- installed = symbolicName.equals( bundles[i].getSymbolicName() ) && version.equals( ver );
+ final Version ver = bundles[i].getVersion();
+ if ( symbolicName.equals(bundles[i].getSymbolicName()))
+ {
+ installed = ver.toString();
+ }
}
- JSONObject json = new JSONObject( resource.getProperties() ) //
+ JSONObject json = new JSONObject()
.put( "id", resource.getId() ) // //$NON-NLS-1$
.put( "presentationname", resource.getPresentationName() ) // //$NON-NLS-1$
.put( "symbolicname", symbolicName ) // //$NON-NLS-1$
diff --git a/webconsole-plugins/obr/src/main/resources/res/plugin.js b/webconsole-plugins/obr/src/main/resources/res/plugin.js
index cd2af1d..bfa3876 100644
--- a/webconsole-plugins/obr/src/main/resources/res/plugin.js
+++ b/webconsole-plugins/obr/src/main/resources/res/plugin.js
@@ -149,7 +149,7 @@
_tr = tr( null, { 'id' : 'row' + _id } , [
td( null, null, [ blockElement ] ),
- td( null, null, [ text(res.installed ? res.version : '') ] )
+ td( null, null, [ text(res.installed) ] )
]);
resTable.append( _tr );
}