geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1351912 - in /geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main: java/org/apache/geronimo/console/obrmanager/ webapp/WEB-INF/view/obrmanager/
Date Wed, 20 Jun 2012 01:42:42 GMT
Author: gawor
Date: Wed Jun 20 01:42:41 2012
New Revision: 1351912

URL: http://svn.apache.org/viewvc?rev=1351912&view=rev
Log:
GERONIMO-6360: Support 'resolve' operation from within the portlet

Added:
    geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp
  (with props)
Modified:
    geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/obrmanager/OBRManagerPortlet.java
    geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/OBRManager.jsp

Modified: geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/obrmanager/OBRManagerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/obrmanager/OBRManagerPortlet.java?rev=1351912&r1=1351911&r2=1351912&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/obrmanager/OBRManagerPortlet.java
(original)
+++ geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/obrmanager/OBRManagerPortlet.java
Wed Jun 20 01:42:41 2012
@@ -30,7 +30,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -46,6 +48,7 @@ import org.apache.felix.bundlerepository
 import org.apache.felix.bundlerepository.Repository;
 import org.apache.felix.bundlerepository.RepositoryAdmin;
 import org.apache.felix.bundlerepository.Requirement;
+import org.apache.felix.bundlerepository.Resolver;
 import org.apache.felix.bundlerepository.Resource;
 import org.apache.geronimo.console.BasePortlet;
 import org.apache.geronimo.console.util.PortletManager;
@@ -65,6 +68,8 @@ public class OBRManagerPortlet extends B
     private PortletRequestDispatcher helpView;
 
     private PortletRequestDispatcher obrManagerView;
+    
+    private PortletRequestDispatcher resolveView;
 
     private static final String SERACH_ACTION = "search";
 
@@ -75,6 +80,8 @@ public class OBRManagerPortlet extends B
     private static final String REFRESH_URL_ACTION = "refreshurl";
 
     private static final String ADD_URL_ACTION = "add_url";
+    
+    private static final String RESOLVE_ACTION = "resolve";
 
     private static final String SEARCH_TYPE_ALL = "ALL";
 
@@ -82,7 +89,7 @@ public class OBRManagerPortlet extends B
         super.init(portletConfig);
         helpView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/obrmanager/OBRManager.jsp");
         obrManagerView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/obrmanager/OBRManager.jsp");
-
+        resolveView = portletConfig.getPortletContext().getRequestDispatcher("/WEB-INF/view/obrmanager/resolve.jsp");
     }
 
     public void destroy() {
@@ -130,7 +137,12 @@ public class OBRManagerPortlet extends B
             String searchType = actionRequest.getParameter("searchType");
             actionResponse.setRenderParameter("searchType", searchType);
         }
-        
+        else if (RESOLVE_ACTION.equals(action)) {
+            actionResponse.setRenderParameter("mode", RESOLVE_ACTION);
+            String[] selectedResources = actionRequest.getParameterValues("selected-resources");
+            actionResponse.setRenderParameter("selected-resources", selectedResources);
+
+        }        
     }
         
     private void refreshRepository(ActionRequest actionRequest) throws Exception {
@@ -228,7 +240,16 @@ public class OBRManagerPortlet extends B
         if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) { // minimal view
             return;
         } else { // normal and maximal view
-
+            if (RESOLVE_ACTION.equals(renderRequest.getParameter("mode"))) {
+                try {
+                    resolveResources(renderRequest, renderResponse);
+                } catch (Exception e) {
+                    addErrorMessage(renderRequest, getLocalizedString(renderRequest, "consolebase.obrmanager.err.actionError"),
e.getMessage());
+                    logger.error("Exception", e);
+                }
+                return;
+            }
+            
             BundleContext bundleContext = getBundleContext(renderRequest);
             ServiceReference reference = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
             RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(reference);
@@ -543,7 +564,46 @@ public class OBRManagerPortlet extends B
             logger.error("Error while persisting repository list", e);
         }
     }
+
+    private void resolveResources(RenderRequest request, RenderResponse response) throws
Exception {
+        String[] selectedResources = request.getParameterValues("selected-resources");
+        if (selectedResources == null || selectedResources.length == 0) {
+            throw new IllegalArgumentException("No resources selected");
+        }
+        
+        BundleContext bundleContext = getBundleContext(request);
+        ServiceReference reference = null;
+            
+        try {
+            reference = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
+            RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(reference);
         
+            Map<String, Resource> resourceMap = new HashMap<String, Resource>();
+            Resource[] resources = getAllResources(repositoryAdmin);
+            for (Resource resource : resources) {
+                resourceMap.put(resource.getSymbolicName() + "/" + resource.getVersion(),
resource);
+            }
+                    
+            Resolver resolver = repositoryAdmin.resolver();
+                    
+            for (String resourceName : selectedResources) {
+                Resource resource = resourceMap.get(resourceName);
+                if (resource == null) {
+                    throw new IllegalArgumentException("Resource not found: " + resourceName);
+                }
+                resolver.add(resource);
+            }
+            
+            request.setAttribute("resolved", resolver.resolve());
+            request.setAttribute("resolver", resolver);
+            resolveView.include(request, response);
+        } finally {
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+    }        
+
     private BundleContext getBundleContext(PortletRequest request) {
         return (BundleContext) request.getPortletSession().getPortletContext().getAttribute("osgi-bundlecontext");
     }

Modified: geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/OBRManager.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/OBRManager.jsp?rev=1351912&r1=1351911&r2=1351912&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/OBRManager.jsp
(original)
+++ geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/OBRManager.jsp
Wed Jun 20 01:42:41 2012
@@ -119,8 +119,12 @@
 
 <!-- show resource bundle list -->
 <c:if test="${resources!=null}">
+
+<form name="selection-form" method="POST" action="<portlet:actionURL><portlet:param
name='action' value='resolve'/></portlet:actionURL>">
+
 <table width="100%" class="TableLine" summary="Bundle List" border="0">
     <tr class="DarkBackground">
+        <th>Selected</th>
         <th>Symbolic Name and Version</th>
     </tr>
     <c:set var="backgroundClass" value='MediumBackground'/>
@@ -135,6 +139,9 @@
         </c:otherwise>
     </c:choose>
     <tr class="${backgroundClass}" onmouseover="highlightBgColor(this)" onmouseout="recoverBgColor(this)">
+        <td align="center">
+            <input name="selected-resources" type="checkbox" value="${resourceInfo.symbolicName}/${resourceInfo.version}"/>
+        </td>
         <!-- bundle symbolicName -->
         <td onclick="showHideById('${resourceInfo.id}')">
             <div style="cursor:pointer;clear:both;" onmouseover="highlightBgColor(this)"
onmouseout="recoverBgColor(this)">${resourceInfo.symbolicName} (${resourceInfo.version})</div>
@@ -179,4 +186,7 @@
     </tr>
     </c:forEach>
 </table>
+    </p>
+    <input type="submit" value="Resolve"/> 
+</form>
 </c:if>

Added: geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp?rev=1351912&view=auto
==============================================================================
--- geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp
(added)
+++ geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp
Wed Jun 20 01:42:41 2012
@@ -0,0 +1,171 @@
+<%--
+   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.
+--%>
+
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+
+<fmt:setBundle basename="consolebase"/>
+
+<c:choose>
+    <c:when test="${resolved == true}">
+        <h2>All resources resolved successfully</h2>
+
+        <b>Resolved resources:</b>
+        <table width="100%" class="TableLine" summary="Resolved Resources">
+            <tr class="DarkBackground">
+                <th scope="col" width="80%">Symbolic Name</th>
+                <th scope="col" width="20%">Version</th>
+            </tr>
+
+            <c:set var="backgroundClass" value='MediumBackground' />
+            <c:forEach var="resource" items="${resolver.addedResources}">
+                <c:choose>
+                    <c:when test="${backgroundClass == 'MediumBackground'}">
+                        <c:set var="backgroundClass" value='LightBackground' />
+                    </c:when>
+                    <c:otherwise>
+                        <c:set var="backgroundClass" value='MediumBackground' />
+                    </c:otherwise>
+                </c:choose>
+
+                <tr class="${backgroundClass}" onmouseover="highlightBgColor(this)" onmouseout="recoverBgColor(this)">
+                    <!-- resource name -->
+                    <td>${resource.symbolicName}</td>
+
+                    <!-- resource version -->
+                    <td>${resource.version}</td>
+                </tr>
+
+            </c:forEach>
+        </table>
+
+        <c:choose>
+            <c:when test="${empty(resolver.requiredResources) && empty(resolver.optionalResources)}">
+                <!-- no additional dependencies -->
+            </c:when>
+            <c:otherwise>
+                <br />
+                <b>Additional dependent resources:</b>
+                <table width="100%" class="TableLine" summary="Required Resources">
+                    <tr class="DarkBackground">
+                        <th scope="col" width="70%">Symbolic Name</th>
+                        <th scope="col" width="20%">Version</th>
+                        <th scope="col" width="10%">Required</th>
+                    </tr>
+
+                    <c:set var="backgroundClass" value='MediumBackground' />
+
+                    <c:if test="${!empty(resolver.requiredResources)}">
+                        <c:forEach var="resource" items="${resolver.requiredResources}">
+                            <c:choose>
+                                <c:when test="${backgroundClass == 'MediumBackground'}">
+                                    <c:set var="backgroundClass" value='LightBackground'
/>
+                                </c:when>
+                                <c:otherwise>
+                                    <c:set var="backgroundClass" value='MediumBackground'
/>
+                                </c:otherwise>
+                            </c:choose>
+
+                            <tr class="${backgroundClass}" onmouseover="highlightBgColor(this)"
+                                onmouseout="recoverBgColor(this)">
+                                <!-- resource name -->
+                                <td>${resource.symbolicName}</td>
+
+                                <!-- resource version -->
+                                <td>${resource.version}</td>
+
+                                <td>Yes</td>
+                            </tr>
+                        </c:forEach>
+                    </c:if>
+
+                    <c:if test="${!empty(resolver.optionalResources)}">
+                        <c:forEach var="resource" items="${resolver.optionalResources}">
+                            <c:choose>
+                                <c:when test="${backgroundClass == 'MediumBackground'}">
+                                    <c:set var="backgroundClass" value='LightBackground'
/>
+                                </c:when>
+                                <c:otherwise>
+                                    <c:set var="backgroundClass" value='MediumBackground'
/>
+                                </c:otherwise>
+                            </c:choose>
+
+                            <tr class="${backgroundClass}" onmouseover="highlightBgColor(this)"
+                                onmouseout="recoverBgColor(this)">
+                                <!-- resource name -->
+                                <td>${resource.symbolicName}</td>
+
+                                <!-- resource version -->
+                                <td>${resource.version}</td>
+
+                                <td>No</td>
+                            </tr>
+                        </c:forEach>
+                    </c:if>
+
+                </table>
+            </c:otherwise>
+        </c:choose>
+        
+        <p/>
+        
+        <form name="resolve-form" action="<portlet:actionURL/>">
+            <input type="submit" value='<fmt:message key="consolebase.common.return"/>'
onclick="history.go(-1); return false;" />
+        </form>
+
+    </c:when>
+
+    <c:otherwise>
+       <h2>One or more resources cannot be resolved</h2>
+       
+       <b>Unsatisfied requirements:</b>
+       <table width="100%" class="TableLine" summary="Unsatisfied Requirements">
+            <tr class="DarkBackground">
+                <th scope="col" width="20%">Symbolic Name</th>
+                <th scope="col" width="80%">Unsatisfied Requirement</th>
+            </tr>
+
+            <c:set var="backgroundClass" value='MediumBackground' />
+            <c:forEach var="reason" items="${resolver.unsatisfiedRequirements}">
+                <c:choose>
+                    <c:when test="${backgroundClass == 'MediumBackground'}">
+                        <c:set var="backgroundClass" value='LightBackground' />
+                    </c:when>
+                    <c:otherwise>
+                        <c:set var="backgroundClass" value='MediumBackground' />
+                    </c:otherwise>
+                </c:choose>
+
+                <tr class="${backgroundClass}" onmouseover="highlightBgColor(this)" onmouseout="recoverBgColor(this)">
+                    <!-- resource name -->
+                    <td>${reason.resource.symbolicName}</td>
+
+                    <!-- requirement -->
+                    <td>${reason.requirement.filter}</td>
+                </tr>
+
+            </c:forEach>
+        </table>
+        
+        <p/>
+        
+        <form name="resolve-form" action="<portlet:actionURL/>">
+            <input type="submit" value='<fmt:message key="consolebase.common.return"/>'
onclick="history.go(-1); return false;" />
+        </form>
+    </c:otherwise>
+</c:choose>

Propchange: geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/branches/3.0/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/obrmanager/resolve.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message