geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r1078438 [1/2] - in /geronimo/server/trunk/plugins/console: console-base-portlets/ console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ console-base-portlets/src/main/webapp/WEB-INF/ console-base-portlets/src/main/...
Date Sun, 06 Mar 2011 09:42:30 GMT
Author: rwonly
Date: Sun Mar  6 09:42:29 2011
New Revision: 1078438

URL: http://svn.apache.org/viewvc?rev=1078438&view=rev
Log:
GERONIMO-5847 Create pure html OSGi portlet

Added:
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleInfo.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleState.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleType.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleUtil.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ExtendedBundleInfo.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ManifestHeader.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/PackageInfo.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/SimpleBundleInfo.java   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/BundleManager.jsp   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/ShowManifest.jsp   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/ShowWiredBundles.jsp   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/images/bundle_delete.png   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/images/bundle_refresh.png   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/images/bundle_start.png   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/images/bundle_stop.png   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/images/bundle_update.png   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/images/icon_mf.png   (with props)
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/images/icon_wb.png   (with props)
    geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/images/ico_ariesapp_16x16.gif   (with props)
    geronimo/server/trunk/plugins/console/console-portal-driver/src/main/webapp/images/ico_osgibundles_16x16.gif   (with props)
Removed:
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/maximized.jsp
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/bundlemanager/normal.jsp
Modified:
    geronimo/server/trunk/plugins/console/console-base-portlets/pom.xml
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/portlet.xml
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/web.xml
    geronimo/server/trunk/plugins/console/console-tomcat/src/main/plan/plan.xml

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/pom.xml?rev=1078438&r1=1078437&r2=1078438&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/pom.xml (original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/pom.xml Sun Mar  6 09:42:29 2011
@@ -94,7 +94,14 @@
             <artifactId>org.apache.servicemix.bundles.commons-io</artifactId>
             <scope>provided</scope>
         </dependency>
-
+        
+        <!-- FIXME : this should be replaced by org.apache.aries.util in next release -->
+        <dependency>
+            <groupId>org.apache.aries.application</groupId>
+            <artifactId>org.apache.aries.application.utils</artifactId>
+            <version>0.2.1</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <!-- Build configuration -->

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleInfo.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleInfo.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleInfo.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,26 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.bundlemanager;
+
+public interface BundleInfo{
+    public long getBundleId();
+    public String getBundleVersion();
+    public String getSymbolicName();
+    
+
+}

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java?rev=1078438&r1=1078437&r2=1078438&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java (original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleManagerPortlet.java Sun Mar  6 09:42:29 2011
@@ -17,11 +17,20 @@
 
 package org.apache.geronimo.console.bundlemanager;
 
+import java.io.File;
 import java.io.IOException;
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Comparator;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -33,287 +42,822 @@ import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
 
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.portlet.PortletFileUpload;
 import org.apache.geronimo.console.BasePortlet;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
-import org.apache.geronimo.kernel.management.State;
-import org.apache.geronimo.kernel.util.BundleUtil;
+import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.kernel.config.ConfigurationInfo;
+import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.xbean.osgi.bundle.util.BundleDescription;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.startlevel.StartLevel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class BundleManagerPortlet extends BasePortlet {
 
     private static final Logger logger = LoggerFactory.getLogger(BundleManagerPortlet.class);
+    
+    private static final String SERACH_ACTION = "search";
+    
+    private static final String LIST_ACTION = "list";
+    
+    private static final String INSTALL_ACTION = "install";
+    
+    private static final String BUNDLE_ACTION = "bundle";
 
-    private static final String START_ACTION = "start";
+    private static final String START_OPERATION = "start";
 
-    private static final String STOP_ACTION = "stop";
+    private static final String STOP_OPERATION = "stop";
 
-    private static final String RESTART_ACTION = "restart";
+    private static final String UPDATE_OPERATION = "update";
+    
+    private static final String UNINSTALL_OPERATION = "uninstall";
 
-    private static final String UPDATE_ACTION = "update";
+    private PortletRequestDispatcher helpView;
     
-    private static final String UNINSTALL_ACTION = "uninstall";
+    private PortletRequestDispatcher bundleManagerView;
 
-    private static final String CONFIG_INIT_PARAM = "config-type";
+    private PortletRequestDispatcher showManifestView;
+    
+    private PortletRequestDispatcher showWiredBundlesView;
 
-    private PortletRequestDispatcher normalView;
+    //private String moduleType;
 
-    private PortletRequestDispatcher maximizedView;
+    protected void doHelp(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
+        helpView.include(renderRequest, renderResponse);
+    }
 
-    private PortletRequestDispatcher helpView;
+    public void init(PortletConfig portletConfig) throws PortletException {
+        super.init(portletConfig);
+        helpView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/bundlemanager/BundleManager.jsp");
+        bundleManagerView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/bundlemanager/BundleManager.jsp");
+        showManifestView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/bundlemanager/ShowManifest.jsp");
+        showWiredBundlesView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/bundlemanager/ShowWiredBundles.jsp");
 
-    private String moduleType;
+    }
 
+    public void destroy() {
+        bundleManagerView = null;
+        super.destroy();
+    }
+    
     public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException {
-        String action = actionRequest.getParameter("action");
+        
         actionResponse.setRenderParameter("message", ""); // set to blank first
         
-        String id = getConfigID(actionRequest);
-        BundleContext bundleContext = getBundleContext(actionRequest);
+        String page = actionRequest.getParameter("page");
+        
+        if ("view_manifest".equals(page)){
+            // no actions in this page
+            actionResponse.setRenderParameter("page", "view_manifest");
+            
+        }else if ("view_wired_bundles".equals(page)){
+            String id = actionRequest.getParameter("bundleId");;
+            String perspectiveType = actionRequest.getParameter("perspectiveType");
+            //set render params
+            actionResponse.setRenderParameter("page", "view_wired_bundles");
+            actionResponse.setRenderParameter("bundleId", id);
+            actionResponse.setRenderParameter("perspectiveTypeValue", perspectiveType);
+            
+        }else { //main page
+            
+            //we use session to control the listType and searchString for filtering list so that
+            //user can easily turn back to the page that he just jumped out.
+            Object sessionListType = actionRequest.getPortletSession().getAttribute("listTypeValue");
+            if (sessionListType == null || "".equals((String)sessionListType)){
+                //default value
+                actionRequest.getPortletSession().setAttribute("listTypeValue","all");
+            }
+            String listType = (String)actionRequest.getPortletSession().getAttribute("listTypeValue");
+            
+            Object sessionSearchString = actionRequest.getPortletSession().getAttribute("searchStringValue");
+            if (sessionSearchString == null){
+                //default value
+                actionRequest.getPortletSession().setAttribute("searchStringValue","");
+            }
+            String searchString = (String)actionRequest.getPortletSession().getAttribute("searchStringValue");;
+            
+            
+            // process action
+            String action = actionRequest.getParameter("action");
+            if (INSTALL_ACTION.equals(action)){
+                BundleContext bundleContext = getBundleContext(actionRequest);
+                
+                //get the StartLeval object
+                ServiceReference startLevelRef = bundleContext.getServiceReference(StartLevel.class.getCanonicalName());
+                StartLevel startLevelService = (StartLevel) bundleContext.getService(startLevelRef);
+                
+                processInstallAction(actionRequest, bundleContext,startLevelService);
+                
+                listType = "all";
+                searchString = "";
+                
+            }else if (SERACH_ACTION.equals(action)){
+                searchString = actionRequest.getParameter("searchString");
+                
+            }else if (LIST_ACTION.equals(action)){
+                listType = actionRequest.getParameter("listType");
+                searchString = "";
+                
+            }else if (BUNDLE_ACTION.equals(action)){ //start/stop/restart/update/uninstall actions
+                
+                String id = actionRequest.getParameter("bundleId");;
+                BundleContext bundleContext = getBundleContext(actionRequest);
 
-        try {
-            Bundle bundle = bundleContext.getBundle(Long.parseLong(id));
+                String operation = actionRequest.getParameter("operation");
+                
+                try {
+                    Bundle bundle = bundleContext.getBundle(Long.parseLong(id));
 
-            if (START_ACTION.equals(action)) {
-                bundle.start();
-            } else if (STOP_ACTION.equals(action)) {
-                bundle.stop();
-                addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.infoMsg02"));
-            } else if (UNINSTALL_ACTION.equals(action)) {
-                bundle.uninstall();
-                addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.infoMsg04") + "<br />" + getSymbolicName(bundle));
-            } else if (RESTART_ACTION.equals(action)) {
-                bundle.stop();
-                bundle.start();
-                addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.infoMsg03"));
-            } else if (UPDATE_ACTION.equals(action)) {
-                bundle.update();
-                addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.infoMsg19"));
-            } else {
-                addWarningMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.warnMsg01") + action + "<br />");
-                throw new PortletException("Invalid value for changeState: " + action);
-            }            
-        } catch (Throwable e) {
-            addErrorMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.errorMsg03"));
-            logger.error("Exception", e);
+                    if (START_OPERATION.equals(operation)) {
+                        bundle.start();
+                        addInfoMessage(actionRequest, "bundle started");
+                    } else if (STOP_OPERATION.equals(operation)) {
+                        bundle.stop();
+                        addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.infoMsg02"));
+                    } else if (UNINSTALL_OPERATION.equals(operation)) {
+                        bundle.uninstall();
+                        addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.infoMsg04") + "<br />" + BundleUtil.getSymbolicName(bundle));
+                    } else if (UPDATE_OPERATION.equals(operation)) {
+                        bundle.update();
+                        addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.infoMsg19"));
+                    } else {
+                        addWarningMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.warnMsg01") + action + "<br />");
+                        throw new PortletException("Invalid value for changeState: " + action);
+                    }            
+                } catch (Throwable e) {
+                    addErrorMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.errorMsg03"), e.getMessage());
+                    logger.error("Exception", e);
+                }
+            }
+            
+            // set listType and searchString in session
+            actionRequest.getPortletSession().setAttribute("listTypeValue", listType);
+            actionRequest.getPortletSession().setAttribute("searchStringValue", searchString);
+            
+            // set the values, which come from session, to render parameter
+            actionResponse.setRenderParameter("listTypeValue", listType);
+            actionResponse.setRenderParameter("searchStringValue", searchString);
         }
+            
     }
-    
-    
-    private BundleContext getBundleContext(PortletRequest request) {
-        return (BundleContext) request.getPortletSession().getPortletContext().getAttribute("osgi-bundlecontext");
-    }
-    
-    private String getConfigID(ActionRequest actionRequest) {
-        return actionRequest.getParameter("bundleId");
-    }
 
+
+    
     protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
-        if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
+        
+        
+        if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) { // minimal view
             return;
-        }
-
-        List<ModuleDetails> moduleDetails = new ArrayList<ModuleDetails>();
             
-        Bundle[] bundles = getBundleContext(renderRequest).getBundles();
-        for (Bundle bundle : bundles) {
-            String contextPath = getContextPath(bundle);
-            if (ConfigurationModuleType.WAB.getName().equalsIgnoreCase(moduleType)) {
-                ModuleDetails details = new ModuleDetails(bundle, BundleType.WAB);
-                if (contextPath != null) {
-                    details.getContextPaths().add(contextPath);
-                    moduleDetails.add(details);
+        } else { // normal and maximal view
+            
+            String page = renderRequest.getParameter("page");
+            
+            if ("view_manifest".equals(page)){
+                BundleContext bundleContext = getBundleContext(renderRequest);
+                
+                long id = Long.valueOf(renderRequest.getParameter("bundleId"));
+                Bundle bundle = bundleContext.getBundle(id);
+                
+                List<ManifestHeader> manifestHeaders = new ArrayList<ManifestHeader>();
+                Dictionary<String,String> headers = bundle.getHeaders();
+                Enumeration<String> keys = headers.keys();
+                while(keys.hasMoreElements()){
+                    String key = (String)keys.nextElement();
+                    if (key.equals("Import-Package")||key.equals("Export-Package")||key.equals("Ignore-Package")||key.equals("Private-Package")||key.equals("Export-Service")){
+                        manifestHeaders.add(new ManifestHeader(key, ManifestHeader.formatPackageHeader((String)headers.get(key))));
+                    } else {
+                        manifestHeaders.add(new ManifestHeader(key, (String)headers.get(key)));
+                    }
                 }
-            } else {
-                ModuleDetails details = new ModuleDetails(bundle, BundleType.REGULAR);
-                if (contextPath != null) {
-                    details.getContextPaths().add(contextPath);
+                
+                SimpleBundleInfo bundleInfo = new SimpleBundleInfo(bundle);
+                
+                Collections.sort(manifestHeaders);
+                renderRequest.setAttribute("manifestHeaders", manifestHeaders);
+                renderRequest.setAttribute("bundleInfo", bundleInfo);
+                showManifestView.include(renderRequest, renderResponse);
+                
+            }else if("view_wired_bundles".equals(page)) {
+                
+                BundleContext bundleContext = getBundleContext(renderRequest);
+                
+                long id = Long.valueOf(renderRequest.getParameter("bundleId"));
+                Bundle bundle = bundleContext.getBundle(id);
+                
+                String perspectiveType = renderRequest.getParameter("perspectiveTypeValue");
+                if (perspectiveType == null || perspectiveType == "") perspectiveType = "package"; //when we access this page with a renderURL, we need the default value
+                
+                ServiceReference reference = bundleContext.getServiceReference(PackageAdmin.class.getName());
+                PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(reference);
+                
+
+                Set<PackageBundlePair> importingPairs = getImportingPairs(packageAdmin, bundle);
+                Set<PackageBundlePair> exportingPairs = getExportingPairs(packageAdmin, bundle);
+                
+                if ("package".equals(perspectiveType)){
+                    List<PackagePerspective> importingPackagePerspectives = getPackagePerspectives(importingPairs);
+                    List<PackagePerspective> exportingPackagePerspectives = getPackagePerspectives(exportingPairs);
+                    
+                    Collections.sort(importingPackagePerspectives);
+                    Collections.sort(exportingPackagePerspectives);
+                    
+                    renderRequest.setAttribute("importingPackagePerspectives", importingPackagePerspectives);
+                    renderRequest.setAttribute("exportingPackagePerspectives", exportingPackagePerspectives);
+                }else{  //"bundle".equals(perspectiveType)){
+                    List<BundlePerspective> importingBundlePerspectives = getBundlePerspectives(importingPairs);
+                    List<BundlePerspective> exportingBundlePerspectives = getBundlePerspectives(exportingPairs);
+                    
+                    Collections.sort(importingBundlePerspectives);
+                    Collections.sort(exportingBundlePerspectives);
+                    
+                    renderRequest.setAttribute("importingBundlePerspectives", importingBundlePerspectives);
+                    renderRequest.setAttribute("exportingBundlePerspectives", exportingBundlePerspectives);
                 }
-                moduleDetails.add(details);
+                                
+                SimpleBundleInfo bundleInfo = new SimpleBundleInfo(bundle);
+                
+                renderRequest.setAttribute("bundleInfo", bundleInfo);
+                renderRequest.setAttribute("perspectiveTypeValue", perspectiveType);
+                
+                showWiredBundlesView.include(renderRequest, renderResponse);
+                
+            }else{  // main page
+
+                String listType = renderRequest.getParameter("listTypeValue");
+                if (listType == null || listType == "") listType = "all"; //when we access this page with a renderURL, we need the default value
+                String searchString = renderRequest.getParameter("searchStringValue");
+                if (searchString == null) searchString = ""; //when we access this page with a renderURL, we need the default value
+                
+                BundleContext bundleContext = getBundleContext(renderRequest);
+                
+                // retrieve bundle infos
+                List<ExtendedBundleInfo> bundleInfos = new ArrayList<ExtendedBundleInfo>();
+                
+                // get the StartLeval object
+                ServiceReference startLevelRef = bundleContext.getServiceReference(StartLevel.class.getCanonicalName());
+                StartLevel startLevelService = (StartLevel) bundleContext.getService(startLevelRef);
+                
+                // get configured bundle Ids
+                Set<Long> configedBundleIds = getConfigedBundleIds();
+                
+                Bundle[] bundles = bundleContext.getBundles();
+                for (Bundle bundle : bundles) {
+                    
+                    if (searchString != "" && !matchBundle(bundle, searchString)){
+                        continue;
+                    }
+                    
+                    // construct the result bundleInfos by listType
+                    if ("wab".equals(listType)){
+                        if (checkWABBundle(bundle)){
+                            ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configedBundleIds);
+                            bundleInfos.add(info);
+                        }
+                    }else if ("blueprint".equals(listType)){
+                        if (checkBlueprintBundle(bundle)){
+                            ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configedBundleIds);
+                            bundleInfos.add(info);
+                        }
+                    }else if ("system".equals(listType)){
+                        if (checkSysBundle(bundle,startLevelService)){
+                            ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configedBundleIds);
+                            bundleInfos.add(info);
+                        }
+                    }else if ("configuration".equals(listType)){
+                        if (checkConfigedBundle(bundle,configedBundleIds)){
+                            ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configedBundleIds);
+                            bundleInfos.add(info);
+                        }
+                    }else{
+                        ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configedBundleIds);
+                        bundleInfos.add(info);
+                    }
+                }
+                
+                Collections.sort(bundleInfos, new BundleIdDescComparator());
+                renderRequest.setAttribute("extendedBundleInfos", bundleInfos);
+                
+                // set the values to render attribute
+                renderRequest.setAttribute("listTypeValue", listType);
+                renderRequest.setAttribute("searchStringValue", searchString);
+                
+                renderRequest.setAttribute("initStartLevel", startLevelService.getInitialBundleStartLevel());
+                
+                if (bundleInfos.size() == 0) {
+                    addWarningMessage(renderRequest, getLocalizedString(renderRequest, "consolebase.warnMsg02"));
+                }
+                
+                bundleManagerView.include(renderRequest, renderResponse);
+                
             }
         }
+    }
+    
+    private ExtendedBundleInfo createExtendedBundleInfo(Bundle bundle, StartLevel startLevelService,Set<Long> configedBundleIds){
+        ExtendedBundleInfo info = new ExtendedBundleInfo(bundle);
+        
+        String contextPath = getContextPath(bundle);
+        if (contextPath != null && contextPath!="") {
+            info.addContextPath(contextPath);
+            info.addType(BundleType.WAB);
+        }
         
-        Collections.sort(moduleDetails);
-        renderRequest.setAttribute("configurations", moduleDetails);
-        renderRequest.setAttribute("showWebInfo", Boolean.valueOf(showWebInfo()));
-        if (moduleDetails.size() == 0) {
-            addWarningMessage(renderRequest, getLocalizedString(renderRequest, "consolebase.warnMsg02"));
+        if (checkBlueprintBundle(bundle)) {
+            info.addType(BundleType.BLUEPRINT);
         }
-        if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
-            normalView.include(renderRequest, renderResponse);
-        } else {
-            maximizedView.include(renderRequest, renderResponse);
+        
+        if (checkSysBundle(bundle, startLevelService)) {
+            info.addType(BundleType.SYSTEM);
+        }
+        
+        if (checkConfigedBundle(bundle,configedBundleIds)){
+            info.addType(BundleType.CONFIGURATION);
         }
+        
+        return info;
     }
-   
+    
+    private BundleContext getBundleContext(PortletRequest request) {
+        return (BundleContext) request.getPortletSession().getPortletContext().getAttribute("osgi-bundlecontext");
+    }
+    
+    private static boolean matchBundle(Bundle bundle, String searchString){
+        if (bundle.getSymbolicName() == null || (bundle.getSymbolicName() != null && bundle.getSymbolicName().indexOf(searchString) == -1)){
+            return false;
+        }
+        return true;
+    }
+    
     private static String getContextPath(Bundle bundle) {
-        return (String) bundle.getHeaders().get(BundleUtil.WEB_CONTEXT_PATH_HEADER);
+        Object path = bundle.getHeaders().get(BundleUtil.WEB_CONTEXT_PATH_HEADER);
+        if (path!=null) {
+            return (String)path;
+        }
+        return null;
     }
     
-    private static String getBundleName(Bundle bundle) {
-        String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
-        name = (name == null) ? bundle.getSymbolicName() : name;
-        name = (name == null) ? bundle.getLocation() : name;
-        return name;
+    private static boolean checkWABBundle(Bundle bundle){
+        String contextPath = getContextPath(bundle);
+        if (contextPath != null && contextPath!="") {
+            return true;
+        }
+        return false;
     }
     
-    private static String getSymbolicName(Bundle bundle) {
-        String name = bundle.getSymbolicName();
-        if (name == null) {
-            name = bundle.getLocation();
+    private static boolean checkBlueprintBundle(Bundle bundle){
+        // TODO do nothing currently
+        return false;
+    }
+    
+    private static boolean checkSysBundle(Bundle bundle, StartLevel startLevelService){
+        //config.properties set karaf.systemBundlesStartLevel=50
+        if (startLevelService!=null && startLevelService.getBundleStartLevel(bundle) <= 50){ 
+            return true;
+        }
+        return false;
+    }
+        
+    private static boolean checkConfigedBundle(Bundle bundle, Set<Long> configedBundleIds){
+        // check configuration bundle
+        if (configedBundleIds.contains(bundle.getBundleId())){
+            return true;
         }
-        return name;
+        return false;
     }
     
-    private boolean showWebInfo() {
-        return true;
+    private Set<Long> getConfigedBundleIds(){
+        Set<Long> configedBundleIds = new HashSet<Long> ();
+        
+        ConfigurationManager configManager = PortletManager.getConfigurationManager();
+        List<ConfigurationInfo> infos = configManager.listConfigurations();
+        
+        for (ConfigurationInfo info : infos) {
+            Bundle configedBundle = configManager.getBundle(info.getConfigID());
+            if (configedBundle!=null){
+                configedBundleIds.add(configedBundle.getBundleId());
+            }else{
+                logger.info("Can not find the bundle for configuration: " +info.getConfigID()+ " in configuration manager");
+            }
+        }
+        
+        return configedBundleIds;
     }
-
-    protected void doHelp(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
-        helpView.include(renderRequest, renderResponse);
+    
+    
+    /*******************************
+     * Bundle comparators
+     *******************************/
+    private static class BundleIdComparator implements Comparator<BundleInfo>{
+        @Override
+        public int compare(BundleInfo infoA, BundleInfo infoB) {
+            if (infoA == null && infoB ==null) return 0;
+            if (infoA == null) return -1;
+            if (infoB == null) return 1;
+            return (int) (infoA.getBundleId() - infoB.getBundleId());
+        }
     }
-
-    public void init(PortletConfig portletConfig) throws PortletException {
-        super.init(portletConfig);
-        normalView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/bundlemanager/normal.jsp");
-        maximizedView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/bundlemanager/maximized.jsp");
-        helpView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/bundlemanager/help.jsp");
-        moduleType = getInitParameter(CONFIG_INIT_PARAM);
+    
+    private static class BundleIdDescComparator implements Comparator<BundleInfo>{
+        @Override
+        public int compare(BundleInfo infoA, BundleInfo infoB) {
+            if (infoA == null && infoB ==null) return 0;
+            if (infoA == null) return 1;
+            if (infoB == null) return -1;
+            return (int) (infoB.getBundleId() - infoA.getBundleId());
+        }
     }
-
-    public void destroy() {
-        normalView = null;
-        maximizedView = null;
-        super.destroy();
+    
+    private static class BundleSymbolicComparator implements Comparator<BundleInfo>{
+        @Override
+        public int compare(BundleInfo infoA, BundleInfo infoB) {
+            if (infoA == null && infoB ==null) return 0;
+            if (infoA == null) return -1;
+            if (infoB == null) return 1;
+            return infoA.getSymbolicName().compareTo(infoB.getSymbolicName());
+        }
     }
+    
+    
+    
+    
+    /*************************************************************
+     * Perspective definitions for Wired bundles page
+     *************************************************************/
+    public static class PackagePerspective implements Comparable<PackagePerspective>{
 
-    public static enum BundleType { 
+        private PackageInfo packageInfo;
+        private List<BundleInfo> bundleInfos = new ArrayList<BundleInfo>();
         
-        REGULAR("REGULAR"), WAB("WAB");
+        public PackagePerspective(String packageName, String packageVersion) {
+            this.packageInfo = new PackageInfo(packageName, packageVersion);
+        }
         
-        private final String name;
-
-        BundleType(String name) {
-            this.name = name;
+        public PackagePerspective(PackageInfo packageInfo) {
+            this.packageInfo = packageInfo;
+        }
+        
+        public PackagePerspective(PackageInfo packageInfo, List<BundleInfo> bundleInfos) {
+            this.packageInfo = packageInfo;
+            this.bundleInfos = bundleInfos;
+        }
+        
+        @Override
+        public int compareTo(PackagePerspective another) {
+            if (another != null) {
+                return packageInfo.compareTo(another.packageInfo);
+            } else {
+                return -1;
+            } 
+        }
+        
+        public PackageInfo getPackageInfo() {
+            return packageInfo;
         }
 
-        public String getName() {
-            return name;
-        }      
+        public List<BundleInfo> getBundleInfos() {
+            return bundleInfos;
+        }
+        
+        public void addBundleInfo(BundleInfo info){
+            this.bundleInfos.add(info);
+        }
+        
+        public void sortBundleInfos(Comparator<BundleInfo> comparator){
+            Collections.sort(bundleInfos, comparator);
+        }
     }
     
-    public static enum BundleState {
+    public static class BundlePerspective implements Comparable<BundlePerspective>{
+
+        private BundleInfo bundleInfo;
+        private List<PackageInfo> packageInfos  = new ArrayList<PackageInfo>();
+        private final Comparator<BundleInfo> comparator = new BundleSymbolicComparator();
         
-        UNINSTALLED(Bundle.UNINSTALLED, "Uninstalled"), 
-        INSTALLED(Bundle.INSTALLED, "Installed"), 
-        RESOLVED(Bundle.RESOLVED, "Resolved"),
-        STARTING(Bundle.STARTING, "Starting"), 
-        STOPPING(Bundle.STOPPING, "Stopping"), 
-        ACTIVE(Bundle.ACTIVE, "Active");
+        public BundlePerspective(Bundle bundle) {
+            this.bundleInfo = new SimpleBundleInfo(bundle);
+        }
         
-        private final int state;
-        private final String name;
-
-        BundleState(int state, String name) {
-            this.state = state;
-            this.name = name;
+        public BundlePerspective(BundleInfo info) {
+            this.bundleInfo = info;
         }
-
-        public int getState() {
-            return state;
+        
+        public BundlePerspective(BundleInfo info, List<PackageInfo> packageInfos) {
+            this.bundleInfo = info;
+            this.packageInfos = packageInfos;
         }
         
-        public String getName() {
-            return name;
+        @Override
+        public int compareTo(BundlePerspective another) {
+            if (another != null) {
+                return comparator.compare(bundleInfo, another.bundleInfo);
+            } else {
+                return -1;
+            } 
         }
         
-        public String toString() {
-            return name;
+        public BundleInfo getBundleInfo() {
+            return bundleInfo;
+        }
+
+        public List<PackageInfo> getPackageInfos() {
+            return packageInfos;
         }
         
-        public boolean isRunning() {
-            return state == Bundle.ACTIVE || state == Bundle.STARTING;
+        public void addPackageInfo(PackageInfo info){
+            packageInfos.add(info);
         }
         
-        public boolean isStopped() {
-            return state == Bundle.INSTALLED || state == Bundle.RESOLVED || state == Bundle.STOPPING;
+        public void sortPackageInfos(){
+            Collections.sort(packageInfos);
         }
+    }
+    
+    private Set<PackageBundlePair> getImportingPairs(PackageAdmin packageAdmin, Bundle bundle) {
+        BundleDescription description = new BundleDescription(bundle.getHeaders());
         
-        public static BundleState getState(Bundle bundle) {
-            int state = bundle.getState();
-            switch (state) {
-            case Bundle.UNINSTALLED:
-                return BundleState.UNINSTALLED;
-            case Bundle.INSTALLED:
-                return BundleState.INSTALLED;
-            case Bundle.RESOLVED:
-                return BundleState.RESOLVED;
-            case Bundle.STOPPING:
-                return BundleState.STOPPING;
-            case Bundle.STARTING:
-                return BundleState.STARTING;            
-            case Bundle.ACTIVE:
-                return BundleState.ACTIVE;
+        Set<PackageBundlePair> importingPairs = new HashSet<PackageBundlePair>();
+
+        // handle static wire via Import-Package
+        List<BundleDescription.ImportPackage> imports = description.getExternalImports();
+        for (BundleDescription.ImportPackage packageImport : imports) {
+            ExportedPackage[] exportedPackages = packageAdmin.getExportedPackages(packageImport.getName());
+            if (exportedPackages!=null){
+                for (ExportedPackage exportedPackage : exportedPackages) {
+                    Bundle[] importingBundles = exportedPackage.getImportingBundles();
+                    if (importingBundles != null) {
+                        for (Bundle importingBundle : importingBundles) {
+                            if (importingBundle == bundle) {
+                                importingPairs.add(new PackageBundlePair(exportedPackage, exportedPackage.getExportingBundle()));
+                            }
+                        }
+                    }
+                }
             }
-            throw new IllegalStateException("Unknown state: " + state);
         }
+        
+        //TODO 1. sometimes, there might be same pairs in the result set.
+        //TODO 2. the result set may contains 2 items which have the same package name but different versions.
+        
+        // handle dynamic wire via DynamicImport-Package
+//        if (!description.getDynamicImportPackage().isEmpty()) {
+//            for (Bundle b : bundle.getBundleContext().getBundles()) {
+//                ExportedPackage[] exports = packageAdmin.getExportedPackages(b);
+//                Bundle wiredBundle = getWiredBundle(bundle, exports);
+//                if (exports != null) {
+//                    for (ExportedPackage exportedPackage : exports) {
+//                        Bundle[] importingBundles = exportedPackage.getImportingBundles();
+//                        if (importingBundles != null) {
+//                            for (Bundle importingBundle : importingBundles) {
+//                                if (importingBundle == bundle) {
+//                                    pbPairs.put(exportedPackage, wiredBundle);
+//                                }
+//                            }
+//                        }
+//                    }
+//                }
+//              
+//            }
+//        }
+        
+        return importingPairs;
     }
     
-    /**
-     * Convenience data holder for portlet that displays deployed modules.
-     * Includes context path information for web modules.
-     */
-    public static class ModuleDetails implements Comparable<ModuleDetails>, Serializable {
-        private static final long serialVersionUID = -7022687152297202079L;
-        private final long bundleId;
-        private final String symbolicName;
-        private final String bundleName;
-        private final BundleType type;
-        private final BundleState state;
-        private List<String> contextPaths = new ArrayList<String>();
+    
+    private Set<PackageBundlePair> getExportingPairs(PackageAdmin packageAdmin, Bundle bundle) {
+        
+        Set<PackageBundlePair> exportingPairs = new HashSet<PackageBundlePair> ();
+        
+        ExportedPackage[] exportedPackages = packageAdmin.getExportedPackages(bundle);
+        
+        if (exportedPackages != null){
+            for (ExportedPackage exportedPackage : exportedPackages) {
+                Bundle[] importingBundles = exportedPackage.getImportingBundles();
+                if (importingBundles != null) {
+                    for (Bundle importingBundle : importingBundles) {
+                        exportingPairs.add(new PackageBundlePair(exportedPackage, importingBundle));
+                        
+                    }
+                }
+            }
+        }
+        
+        return exportingPairs;
 
-        public ModuleDetails(Bundle bundle, BundleType type) {
-            this.bundleId = bundle.getBundleId();
-            this.symbolicName = BundleManagerPortlet.getSymbolicName(bundle);
-            this.bundleName = BundleManagerPortlet.getBundleName(bundle);
-            this.state = BundleState.getState(bundle);
-            this.type = type;
+    }
+    
+    private static class PackageBundlePair {
+        final ExportedPackage exportedPackage;
+        final Bundle bundle;
+        
+        PackageBundlePair(ExportedPackage exportedPackage,Bundle bundle ){
+            this.exportedPackage = exportedPackage;
+            this.bundle = bundle;
         }
         
-        public int compareTo(ModuleDetails o) {
-            if (o != null) {
-                return (int) (bundleId - o.bundleId);
-            } else {
-                return -1;
+        @Override
+        public boolean equals(Object obj) {
+            if (obj == null) {
+                return false;
+            }
+
+            if (getClass() != obj.getClass()) {
+                return false;
             }
-        }
 
-        public long getBundleId() {
-            return bundleId;
+            final PackageBundlePair other = (PackageBundlePair) obj;
+            if (this.exportedPackage != other.exportedPackage && (this.exportedPackage == null || !this.exportedPackage.equals(other.exportedPackage))) {
+                return false;
+            }
+            if (this.bundle != other.bundle && (this.bundle == null || !this.bundle.equals(other.bundle))) {
+                return false;
+            }
+
+            return true;
+            
         }
+        
+        @Override
+        public int hashCode() {
+            int hash = 11;
+            hash = 17* hash + (exportedPackage != null ? exportedPackage.hashCode():0);
+            hash = 17 * hash + (bundle != null ? bundle.hashCode():0);
 
-        public BundleState getState() {
-            return state;
+            return hash;
         }
+        
+    }
+    
 
-        public BundleType getType() {
-            return type;
+    private List<PackagePerspective> getPackagePerspectives(Set<PackageBundlePair> pairs){
+        Map<PackageInfo,List<BundleInfo>> pbs = new HashMap<PackageInfo,List<BundleInfo>>();
+        
+        for (PackageBundlePair pair : pairs) {
+            
+            PackageInfo packageInfo = new PackageInfo(pair.exportedPackage.getName(), pair.exportedPackage.getVersion().toString());
+            BundleInfo bundleInfo = new SimpleBundleInfo(pair.bundle);
+            
+            if (pbs.keySet().contains(packageInfo)){
+                if (!pbs.get(packageInfo).contains(bundleInfo)) {
+                    pbs.get(packageInfo).add(bundleInfo);
+                }
+            } else {
+                List<BundleInfo> bundleInfos = new ArrayList<BundleInfo>();
+                bundleInfos.add(bundleInfo);
+                pbs.put(packageInfo, bundleInfos);
+            }
+            
+        }
+        
+        List<PackagePerspective>packagePerspectives = new ArrayList<PackagePerspective>();
+        BundleSymbolicComparator bsc = new BundleSymbolicComparator();
+        for(Entry<PackageInfo,List<BundleInfo>> entry : pbs.entrySet()){
+            PackagePerspective pp = new PackagePerspective(entry.getKey(),entry.getValue());
+            pp.sortBundleInfos(bsc);
+            packagePerspectives.add(pp);
+        }
+        
+        return packagePerspectives;
+    }
+    
+    private List<BundlePerspective> getBundlePerspectives(Set<PackageBundlePair> pairs){
+        Map<BundleInfo,List<PackageInfo>> pbs = new HashMap<BundleInfo,List<PackageInfo>>();
+        
+        for (PackageBundlePair pair : pairs) {
+            
+            BundleInfo bundleInfo = new SimpleBundleInfo(pair.bundle);
+            PackageInfo packageInfo = new PackageInfo(pair.exportedPackage.getName(), pair.exportedPackage.getVersion().toString());
+            
+            if (pbs.keySet().contains(bundleInfo)){
+                if (!pbs.get(bundleInfo).contains(packageInfo)) {
+                    pbs.get(bundleInfo).add(packageInfo);
+                }
+            } else {
+                List<PackageInfo> packageInfos = new ArrayList<PackageInfo>();
+                packageInfos.add(packageInfo);
+                pbs.put(bundleInfo, packageInfos);
+            }
+            
+        }
+        
+        List<BundlePerspective> bundlePerspectives = new ArrayList<BundlePerspective>();
+        for(Entry<BundleInfo,List<PackageInfo>> entry : pbs.entrySet()){
+            BundlePerspective bp = new BundlePerspective(entry.getKey(),entry.getValue());
+            bp.sortPackageInfos();
+            bundlePerspectives.add(bp);
+        }
+        
+        return bundlePerspectives;
+    }
+    
+    /******************************
+     * Install Action
+     ******************************/
+    private void processInstallAction(ActionRequest request, BundleContext bundleContext,StartLevel startLevelService ) throws PortletException, IOException {
+        if (!PortletFileUpload.isMultipartContent(request)) {
+            throw new PortletException("Expected file upload");
+        }
+
+        // use commons-fileupload to process the request
+        File rootDir = new File(System.getProperty("java.io.tmpdir"));
+        PortletFileUpload uploader = new PortletFileUpload(new DiskFileItemFactory(10240, rootDir));
+        
+        File bundleFile = null;
+        String startAfterInstalled = null;
+        String str_startLevel = null;
+        
+        List<?> items;
+        try {
+            items = uploader.parseRequest(request);
+        } catch (FileUploadException e) {
+            addErrorMessage(request, "file upload failed!");
+            logger.error("file upload failed!",e);
+            return;
         }
 
-        public List<String> getContextPaths() {
-            return contextPaths;
+        // deal with the multipart form data items;
+        for (Iterator<?> i = items.iterator(); i.hasNext();) {
+            FileItem item = (FileItem) i.next();
+            if (!item.isFormField()) {
+                String fieldName = item.getFieldName();
+                String fileName = item.getName().trim();
+                if (fileName.length() != 0) {
+                    int index = fileName.lastIndexOf('\\');
+                    if (index != -1) {
+                        fileName = fileName.substring(index + 1);
+                    }
+                    if ("bundleFile".equals(fieldName)) {
+                        bundleFile = new File(rootDir, fileName);
+                    }
+                }
+                if (bundleFile != null) {
+                    try {
+                        item.write(bundleFile);
+                    } catch (Exception e) {
+                        addErrorMessage(request, "write file failed!");
+                        logger.error("write file failed!", e);
+                        return;
+                    }
+                } else {
+                    addErrorMessage(request, "the file is null!");
+                    logger.error("the file is null!");
+                    return;
+                }
+            } else {
+                if ("startAfterInstalled".equalsIgnoreCase(item.getFieldName())) {
+                    startAfterInstalled = item.getString();
+                } else if ("startLevel".equalsIgnoreCase(item.getFieldName())) {
+                    str_startLevel = item.getString();
+                }
+            }
         }
 
-        public String getSymbolicName() {
-            return symbolicName;
+        // install the uploaded bundle file
+        String url = "file:///" + bundleFile.getCanonicalPath();
+
+        Bundle installedBundle;
+        try {
+            installedBundle = bundleContext.installBundle(url);
+            addInfoMessage(request, "bundle installed");
+        } catch (BundleException e) {
+            addErrorMessage(request, "install bundle failed!");
+            logger.error("install bundle failed!", e);
+            return;
         }
         
-        public String getBundleName() {
-            return bundleName;
+
+        // set start level for the installed bundle
+        int startLevel = -1;
+        try {
+            startLevel = Integer.parseInt(str_startLevel);
+        } catch (NumberFormatException e) {
+            // if can't generated, use the default initialBundleStartLevel
+        }
+        int defaultStartLevel = startLevelService.getInitialBundleStartLevel();
+        if (startLevel != defaultStartLevel && startLevel >= 0) {
+            startLevelService.setBundleStartLevel(installedBundle, startLevel);
+        }
+
+        // if check box "Start" checked, then start the bundle
+        if ("yes".equals(startAfterInstalled)) {
+            try {
+                installedBundle.start();
+                addInfoMessage(request, "bundle started");
+            } catch (BundleException e) {
+                addErrorMessage(request, "start bundle failed!");
+                logger.error("start bundle failed!", e);
+                return;
+            }
+            
         }
-                
     }
 }

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleState.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleState.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleState.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleState.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,77 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.bundlemanager;
+
+import org.osgi.framework.Bundle;
+
+public enum BundleState {
+    
+    UNINSTALLED(Bundle.UNINSTALLED, "Uninstalled"), 
+    INSTALLED(Bundle.INSTALLED, "Installed"), 
+    RESOLVED(Bundle.RESOLVED, "Resolved"),
+    STARTING(Bundle.STARTING, "Starting"), 
+    STOPPING(Bundle.STOPPING, "Stopping"), 
+    ACTIVE(Bundle.ACTIVE, "Active");
+    
+    private final int state;
+    private final String name;
+
+    BundleState(int state, String name) {
+        this.state = state;
+        this.name = name;
+    }
+
+    public int getState() {
+        return state;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public String toString() {
+        return name;
+    }
+    
+    public boolean isRunning() {
+        return state == Bundle.ACTIVE || state == Bundle.STARTING;
+    }
+    
+    public boolean isStopped() {
+        return state == Bundle.INSTALLED || state == Bundle.RESOLVED || state == Bundle.STOPPING;
+    }
+    
+    public static BundleState getState(Bundle bundle) {
+        int state = bundle.getState();
+        switch (state) {
+        case Bundle.UNINSTALLED:
+            return BundleState.UNINSTALLED;
+        case Bundle.INSTALLED:
+            return BundleState.INSTALLED;
+        case Bundle.RESOLVED:
+            return BundleState.RESOLVED;
+        case Bundle.STOPPING:
+            return BundleState.STOPPING;
+        case Bundle.STARTING:
+            return BundleState.STARTING;            
+        case Bundle.ACTIVE:
+            return BundleState.ACTIVE;
+        }
+        throw new IllegalStateException("Unknown state: " + state);
+    }
+}

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleType.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleType.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleType.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleType.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,41 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.bundlemanager;
+
+public enum BundleType { 
+    
+    WAB("WAB"),
+    BLUEPRINT("BLUEPRINT"),
+    CONFIGURATION("CONFIGURATION"),
+    SYSTEM("SYSTEM");
+    
+    
+    private final String name;
+
+    BundleType(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+    
+    public String toString() {
+        return name;
+    }
+    
+}
\ No newline at end of file

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleUtil.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleUtil.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleUtil.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,40 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.bundlemanager;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+public class BundleUtil {
+    
+    public static final String WEB_CONTEXT_PATH_HEADER = "Web-ContextPath";
+    
+    public static String getBundleName(Bundle bundle) {
+        String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
+        name = (name == null) ? bundle.getSymbolicName() : name;
+        name = (name == null) ? bundle.getLocation() : name;
+        return name;
+    }
+    
+    public static String getSymbolicName(Bundle bundle) {
+        String name = bundle.getSymbolicName();
+        if (name == null) {
+            name = bundle.getLocation();
+        }
+        return name;
+    }
+}

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/BundleUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ExtendedBundleInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ExtendedBundleInfo.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ExtendedBundleInfo.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ExtendedBundleInfo.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,54 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.bundlemanager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+
+public class ExtendedBundleInfo extends SimpleBundleInfo {
+
+    private List<BundleType> types = new ArrayList<BundleType>();
+    private List<String> contextPaths = new ArrayList<String>();
+
+    public ExtendedBundleInfo(Bundle bundle) {
+        super(bundle);
+    }
+    
+    public List<BundleType> getTypes() {
+        return types;
+    }
+    
+    public void addType(BundleType type) {
+        types.add(type);
+    }
+    
+    public boolean isOperable(){
+        return !types.contains(BundleType.SYSTEM) && !types.contains(BundleType.CONFIGURATION);
+    }
+
+    public List<String> getContextPaths() {
+        return contextPaths;
+    }
+    
+    public void addContextPath(String path) {
+        contextPaths.add(path);
+    }
+
+}
+

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ExtendedBundleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ManifestHeader.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ManifestHeader.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ManifestHeader.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ManifestHeader.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,118 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.console.bundlemanager;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+
+public class ManifestHeader implements Comparable<ManifestHeader>{
+
+    private String key;
+    private String value;
+    
+    public ManifestHeader(String key, String value){
+        this.key = key;
+        this.value = value;
+    }
+    
+    public int compareTo(ManifestHeader another) {
+        if (another != null) {
+            return key.compareTo(another.key);
+        } else {
+            return -1;
+        }
+    }
+    
+    public String getKey() {
+        return key;
+    }
+    
+    public String getValue() {
+        return value;
+    }
+    
+    public static String formatPackageHeader(String header){
+        List<String> packagesList = ManifestHeaderProcessor.split(header, ",");
+        Collections.sort(packagesList);
+
+        String result = "";
+        for (Iterator<String> it = packagesList.iterator(); it.hasNext(); result+=formatPackageValue(it.next())+"<BR/>");
+        
+        return result;
+    }
+
+    /*
+     * Format a package value from
+     * org.apache.aries.util.tracker;uses:="org.osgi.util.tracker,org.osgi.framework,org.osgi.framework.launch";version="0.2.0.incubating",
+     * to
+     * org.apache.aries.util.tracker;version="0.2.0.incubating",
+     *     uses:="org.osgi.util.tracker,
+     *         org.osgi.framework,
+     *         org.osgi.framework.launch",
+     */
+
+    private static String formatPackageValue(String pkg) {
+        String result = "";
+        
+        String[] parts = pkg.split(";");
+        
+        if (parts!=null && parts.length>0) { //it should at least have a package name;
+            result = parts[0]; 
+        }
+        
+        String uses = "";
+        for (int i=1; i<parts.length;i++){
+            String aPart = parts[i];
+            if (aPart.indexOf("uses:=")!=-1){  //deal with the "uses:=.." specially, because it always very long..
+                uses+=";<BR/>&nbsp;&nbsp;&nbsp;&nbsp;"+"uses:="+"\"";
+                
+                String usesValue = "";
+                if (aPart.indexOf("\"")!=-1){
+                    usesValue = aPart.substring(aPart.indexOf("\"")+1, aPart.lastIndexOf("\""));
+                } else {  // for such using uses:=javassist;
+                    usesValue = aPart.substring(aPart.indexOf(":=")+2);
+                }
+                
+                List<String> usesValueList = ManifestHeaderProcessor.split(usesValue,",");
+                Collections.sort(usesValueList);
+                Iterator<String> usesIT = usesValueList.iterator();
+                if (usesIT.hasNext()){ //it should at least have a value;
+                    uses += usesIT.next();
+                }
+                while (usesIT.hasNext()){
+                    uses += ",<BR/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+usesIT.next();
+                }
+                
+                uses+="\"";
+                
+            } else {  //maybe "version=..", maybe "resolution=.."
+                result += ";"+aPart;
+            }
+        }
+        
+        if (uses!="") result += uses;
+        
+        return result+",";
+    }
+    
+}
+
+

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/ManifestHeader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/PackageInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/PackageInfo.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/PackageInfo.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/PackageInfo.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,79 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.bundlemanager;
+
+
+public class PackageInfo implements Comparable<PackageInfo>{
+    private String packageName;
+    private String packageVersion;
+    
+    public PackageInfo(String packageName, String packageVersion) {
+        this.packageName = packageName;
+        this.packageVersion = packageVersion;
+    }
+    
+    public String getPackageName() {
+        return packageName;
+    }
+    
+    public String getPackageVersion() {
+        return packageVersion;
+    }
+    
+    @Override
+    public int compareTo(PackageInfo another) {
+        if (another != null) {
+            int result = packageName.compareTo(another.packageName);
+            if (result != 0){
+                return result;
+            }else{
+                return packageVersion.compareTo(another.packageVersion);
+            }
+        } else {
+            return -1;
+        } 
+    }
+    
+    @Override
+    public boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (getClass() != o.getClass()) {
+            return false;
+        }
+
+        final PackageInfo other = (PackageInfo) o;
+        if (this.packageName != other.packageName && (this.packageName == null || !this.packageName.equals(other.packageName))) {
+            return false;
+        }
+        if (this.packageVersion != other.packageVersion && (this.packageVersion == null || !this.packageVersion.equals(other.packageVersion))) {
+            return false;
+        }
+
+        return true;
+    }
+    
+    @Override
+    public int hashCode() {
+        int hash = 11;
+        hash = 17* hash + (packageName != null ? packageName.hashCode():0);
+        hash = 17 * hash + (packageVersion != null ? packageVersion.hashCode():0);
+
+        return hash;
+    }
+}
\ No newline at end of file

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/PackageInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/SimpleBundleInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/SimpleBundleInfo.java?rev=1078438&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/SimpleBundleInfo.java (added)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/SimpleBundleInfo.java Sun Mar  6 09:42:29 2011
@@ -0,0 +1,92 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.console.bundlemanager;
+
+import org.osgi.framework.Bundle;
+
+public class SimpleBundleInfo implements BundleInfo{
+    private final long bundleId;
+    private final String symbolicName;
+    private final String bundleVersion;
+    private final String bundleName;
+    private final BundleState state;
+    
+    public SimpleBundleInfo(Bundle bundle){
+        this.bundleId = bundle.getBundleId();
+        this.symbolicName = BundleUtil.getSymbolicName(bundle);
+        this.bundleName = BundleUtil.getBundleName(bundle);
+        this.bundleVersion = bundle.getVersion().toString();
+        this.state = BundleState.getState(bundle);
+    }
+    
+    public long getBundleId() {
+        return bundleId;
+    }
+    
+    public String getSymbolicName() {
+        return symbolicName;
+    }
+    
+    public String getBundleVersion() {
+        return bundleVersion;
+    }
+    
+    public String getBundleName() {
+        return bundleName;
+    }
+    
+    
+    public BundleState getState() {
+        return state;
+    }
+    
+    @Override
+    public boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        }
+        if (getClass() != o.getClass()) {
+            return false;
+        }
+
+        final SimpleBundleInfo other = (SimpleBundleInfo) o;
+        if (this.bundleId != other.bundleId){
+            return false;
+        }
+        if (this.symbolicName != other.symbolicName && (this.symbolicName == null || !this.symbolicName.equals(other.symbolicName))) {
+            return false;
+        }
+        if (this.bundleVersion != other.bundleVersion && (this.bundleVersion == null || !this.bundleVersion.equals(other.bundleVersion))) {
+            return false;
+        }
+
+        return true;
+    }
+    
+    @Override
+    public int hashCode() {
+        int hash = 11;
+        hash = hash + (int)bundleId;
+        hash = 17* hash + (symbolicName != null ? symbolicName.hashCode():0);
+        hash = 17 * hash + (bundleVersion != null ? bundleVersion.hashCode():0);
+
+        return hash;
+    }
+    
+
+}
+

Propchange: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/bundlemanager/SimpleBundleInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/portlet.xml?rev=1078438&r1=1078437&r2=1078438&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/portlet.xml (original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/portlet.xml Sun Mar  6 09:42:29 2011
@@ -400,9 +400,9 @@ limitations under the License.
         </init-param>
     </portlet>
     <portlet>
-        <description>Portlet for displaying WAB modules</description>
-        <portlet-name>WABModules</portlet-name>
-        <display-name>WAB Modules Portlet</display-name>
+        <description>Portlet for displaying bundles</description>
+        <portlet-name>BundleManagerPortlet</portlet-name>
+        <display-name>Bundle Manager Portlet</display-name>
         <portlet-class>org.apache.geronimo.console.bundlemanager.BundleManagerPortlet</portlet-class>
         <expiration-cache>-1</expiration-cache>
         <supports>
@@ -414,14 +414,10 @@ limitations under the License.
         <supported-locale>ja</supported-locale>
         <resource-bundle>portletinfo</resource-bundle>
         <portlet-info>
-            <title>Installed Web Application Bundles (WAB)</title>
-            <short-title>WAB Modules</short-title>
-            <keywords>WAB Application WAB Module</keywords>
+            <title>OSGi Bundles</title>
+            <short-title>OSGi Bundles</short-title>
+            <keywords>OSGi Bundle</keywords>
         </portlet-info>
-        <init-param>
-            <name>config-type</name>
-            <value>WAB</value>
-        </init-param> 
     </portlet>    
     <portlet>
         <description>Portlet for displaying System modules</description>



Mime
View raw message