felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r735636 - in /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core: BundleAction.java BundlesServlet.java InstallAction.java
Date Mon, 19 Jan 2009 09:30:09 GMT
Author: cziegeler
Date: Mon Jan 19 01:30:07 2009
New Revision: 735636

URL: http://svn.apache.org/viewvc?rev=735636&view=rev
Log:
Felix-888 : Add support for {symbolic-name}[:{version}] in the url which can be used instead
of the bundle id to get information of a bundle as json, or perform an action on this bundle.

Removed:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundleAction.java
Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java?rev=735636&r1=735635&r2=735636&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
Mon Jan 19 01:30:07 2009
@@ -28,7 +28,6 @@
 import org.apache.felix.bundlerepository.*;
 import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
 import org.apache.felix.webconsole.internal.Util;
-import org.apache.felix.webconsole.internal.obr.DeployerThread;
 import org.apache.felix.webconsole.internal.servlet.OsgiManager;
 import org.json.JSONException;
 import org.json.JSONWriter;
@@ -36,7 +35,7 @@
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.component.ComponentConstants;
 import org.osgi.service.log.LogService;
-import org.osgi.service.obr.*;
+import org.osgi.service.obr.RepositoryAdmin;
 import org.osgi.service.packageadmin.ExportedPackage;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.startlevel.StartLevel;
@@ -122,7 +121,7 @@
                 {
                     // bundle properties
 
-                    response.setContentType( "text/javascript" );
+                    response.setContentType( "application/json" );
                     response.setCharacterEncoding( "UTF-8" );
 
                     PrintWriter pw = response.getWriter();
@@ -267,20 +266,44 @@
         pathInfo = pathInfo.substring( pathInfo.lastIndexOf( '/' ) + 1 );
 
         // assume bundle Id
-        long bundleId;
         try
         {
-            bundleId = Long.parseLong( pathInfo );
+            final long bundleId = Long.parseLong( pathInfo );
+            if ( bundleId >= 0 )
+            {
+                return getBundleContext().getBundle( bundleId );
+            }
         }
         catch ( NumberFormatException nfe )
         {
-            bundleId = -1;
+            // check if this follows the pattern {symbolic-name}[:{version}]
+            final int pos = pathInfo.indexOf(':');
+            final String symbolicName;
+            final String version;
+            if ( pos == -1 ) {
+                symbolicName = pathInfo;
+                version = null;
+            } else {
+                symbolicName = pathInfo.substring(0, pos);
+                version = pathInfo.substring(pos+1);
+            }
+
+            // search
+            final Bundle[] bundles = getBundleContext().getBundles();
+            for(int i=0; i<bundles.length; i++)
+            {
+                final Bundle bundle = bundles[i];
+                // check symbolic name first
+                if ( symbolicName.equals(bundle.getSymbolicName()) )
+                {
+                    if ( version == null || version.equals(bundle.getHeaders().get(Constants.BUNDLE_VERSION))
)
+                    {
+                        return bundle;
+                    }
+                }
+            }
         }
 
-        if ( bundleId >= 0 )
-        {
-            return getBundleContext().getBundle( bundleId );
-        }
 
         return null;
     }

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java?rev=735636&r1=735635&r2=735636&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/InstallAction.java
Mon Jan 19 01:30:07 2009
@@ -17,10 +17,7 @@
 package org.apache.felix.webconsole.internal.core;
 
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.util.Map;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
@@ -30,9 +27,9 @@
 
 import org.apache.commons.fileupload.FileItem;
 import org.apache.felix.webconsole.AbstractWebConsolePlugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
+import org.apache.felix.webconsole.Action;
+import org.apache.felix.webconsole.internal.BaseManagementPlugin;
+import org.osgi.framework.*;
 import org.osgi.service.log.LogService;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.startlevel.StartLevel;
@@ -41,7 +38,7 @@
 /**
  * The <code>InstallAction</code> TODO
  */
-public class InstallAction extends BundleAction
+public class InstallAction extends BaseManagementPlugin implements Action
 {
 
     public static final String NAME = "install";
@@ -196,7 +193,7 @@
                     }
                 }
             }
-            
+
             if ( updateBundle != null )
             {
 
@@ -273,7 +270,7 @@
                 {
                     bundle.start();
                 }
-                
+
                 return bundle;
             }
         };



Mime
View raw message