geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1350916 - in /geronimo/server/branches/3.0: framework/modules/geronimo-obr/src/main/java/org/apache/geronimo/obr/ plugins/console/console-base-portlets/ plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/obrman...
Date Sat, 16 Jun 2012 12:51:27 GMT
Author: gawor
Date: Sat Jun 16 12:51:27 2012
New Revision: 1350916

URL: http://svn.apache.org/viewvc?rev=1350916&view=rev
Log:
GERONIMO-6360: Support for Geronimo obr refresh

Modified:
    geronimo/server/branches/3.0/framework/modules/geronimo-obr/src/main/java/org/apache/geronimo/obr/GeronimoOBRGBean.java
    geronimo/server/branches/3.0/plugins/console/console-base-portlets/pom.xml
    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/framework/modules/geronimo-obr/src/main/java/org/apache/geronimo/obr/GeronimoOBRGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/framework/modules/geronimo-obr/src/main/java/org/apache/geronimo/obr/GeronimoOBRGBean.java?rev=1350916&r1=1350915&r2=1350916&view=diff
==============================================================================
--- geronimo/server/branches/3.0/framework/modules/geronimo-obr/src/main/java/org/apache/geronimo/obr/GeronimoOBRGBean.java
(original)
+++ geronimo/server/branches/3.0/framework/modules/geronimo-obr/src/main/java/org/apache/geronimo/obr/GeronimoOBRGBean.java
Sat Jun 16 12:51:27 2012
@@ -60,6 +60,8 @@ public class GeronimoOBRGBean implements
 
     private static final Logger LOG = LoggerFactory.getLogger(GeronimoOBRGBean.class);
 
+    public static final String REPOSITORY_NAME = "Geronimo OBR Repository";
+    
     private BundleContext bundleContext;
     private ListableRepository repository;
     private File obrFile;
@@ -117,8 +119,6 @@ public class GeronimoOBRGBean implements
 
     private void generateRepository() throws Exception {
 
-        String obrName = "Geronimo OBR Repository";
-
         org.apache.geronimo.kernel.repository.Repository geronimoRepository = repository;
         Set<Artifact> artifacts = repository.list();
 
@@ -134,7 +134,7 @@ public class GeronimoOBRGBean implements
             }
         }
 
-        generateOBR(obrName, artifacts, geronimoRepository, obrFile);
+        generateOBR(REPOSITORY_NAME, artifacts, geronimoRepository, obrFile);
     }
 
     public static void generateOBR(String obrName, Set<Artifact> artifacts, org.apache.geronimo.kernel.repository.Repository
geronimoRepository, File obrFile) throws IOException, JAXBException {

Modified: geronimo/server/branches/3.0/plugins/console/console-base-portlets/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/console/console-base-portlets/pom.xml?rev=1350916&r1=1350915&r2=1350916&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/console/console-base-portlets/pom.xml (original)
+++ geronimo/server/branches/3.0/plugins/console/console-base-portlets/pom.xml Sat Jun 16
12:51:27 2012
@@ -120,6 +120,13 @@
             <artifactId>org.apache.felix.bundlerepository</artifactId>
             <scope>provided</scope>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.framework</groupId>
+            <artifactId>geronimo-obr</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
 
     </dependencies>
 

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=1350916&r1=1350915&r2=1350916&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
Sat Jun 16 12:51:27 2012
@@ -41,6 +41,7 @@ import org.apache.felix.bundlerepository
 import org.apache.felix.bundlerepository.Requirement;
 import org.apache.felix.bundlerepository.Resource;
 import org.apache.geronimo.console.BasePortlet;
+import org.apache.geronimo.obr.GeronimoOBRGBean;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
@@ -83,40 +84,31 @@ public class OBRManagerPortlet extends B
             IOException {
         actionResponse.setRenderParameter("message", ""); // set to blank first
         
-        BundleContext bundleContext = getBundleContext(actionRequest);
-        ServiceReference reference = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
-        RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(reference);
-        
         String action = actionRequest.getParameter("action");
 
-
         if (ADD_URL_ACTION.equals(action)) {
-            String obrUrl = actionRequest.getParameter("obrUrl");
-
             try {
-                repositoryAdmin.addRepository(new URI(obrUrl).toURL());
-                addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.info.add",
obrUrl));
+                addRepository(actionRequest);
             } catch (Exception e) {
                 addErrorMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.err.actionError")
+ action, e.getMessage());
                 logger.error("Exception", e);
             }
         }
         else if (REFRESH_URL_ACTION.equals(action)) {
-            String uri = actionRequest.getParameter("uri");
-
             try {
-                repositoryAdmin.removeRepository(uri);
-                repositoryAdmin.addRepository(uri);
-                addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.info.refreshurl",
uri));
+                refreshRepository(actionRequest);    
             } catch (Exception e) {
                 addErrorMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.err.actionError")
+ action, e.getMessage());
                 logger.error("Exception", e);
             }
         }
         else if (REMOVE_URL_ACTION.equals(action)) {
-            String uri = actionRequest.getParameter("uri");
-            repositoryAdmin.removeRepository(uri);
-            addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.info.removeurl",
uri));
+            String uri = actionRequest.getParameter("repo.uri");
+            String name = actionRequest.getParameter("repo.name");
+            if (name == null || name.trim().length() == 0) {
+                name = uri;
+            }
+            removeRepository(actionRequest);
         }
         else if (LIST_ACTION.equals(action)) {
             String searchType = SEARCH_TYPE_ALL;
@@ -130,7 +122,92 @@ public class OBRManagerPortlet extends B
         }
         
     }
+        
+    private void refreshRepository(ActionRequest actionRequest) throws Exception {
+        String uri = actionRequest.getParameter("repo.uri");
+        String name = getName(actionRequest.getParameter("repo.name"), uri);
+
+        BundleContext bundleContext = getBundleContext(actionRequest);
+        ServiceReference reference = null;
+        
+        try {
+            if (GeronimoOBRGBean.REPOSITORY_NAME.equals(name)) {
+                reference = bundleContext.getServiceReference(GeronimoOBRGBean.class.getName());
+                GeronimoOBRGBean obrGBean = (GeronimoOBRGBean) bundleContext.getService(reference);
+
+                // do refresh
+                obrGBean.refresh();                
+            } else {
+                reference = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
+                RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(reference);
+
+                // do refresh
+                repositoryAdmin.removeRepository(uri);
+                repositoryAdmin.addRepository(uri);
+            }
+        } finally {
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+        
+        addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.info.refreshurl",
name));
+    }
+    
+    private void removeRepository(ActionRequest actionRequest) {
+        String uri = actionRequest.getParameter("repo.uri");
+        String name = getName(actionRequest.getParameter("repo.name"), uri);
+
+        BundleContext bundleContext = getBundleContext(actionRequest);
+        ServiceReference reference = null;
+        
+        try {
+            reference = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
+            RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(reference);
+
+            // do remove
+            repositoryAdmin.removeRepository(uri);
+        } finally {
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+        
+        addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.info.removeurl",
name));
+    }
+    
+    private void addRepository(ActionRequest actionRequest) throws Exception {
+        String obrUrl = actionRequest.getParameter("obrUrl");
 
+        BundleContext bundleContext = getBundleContext(actionRequest);
+        ServiceReference reference = null;
+        String name = null;
+        
+        try {
+            reference = bundleContext.getServiceReference(RepositoryAdmin.class.getName());
+            RepositoryAdmin repositoryAdmin = (RepositoryAdmin) bundleContext.getService(reference);
+
+            // do add
+            Repository repository = repositoryAdmin.addRepository(new URI(obrUrl).toURL());
+            name = getName(repository.getName(), obrUrl);
+            
+        } finally {
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+        
+        addInfoMessage(actionRequest, getLocalizedString(actionRequest, "consolebase.obrmanager.info.add",
name));        
+    }
+    
+    private static String getName(String name, String uri) {
+        if (name == null || name.trim().length() == 0) {
+            return uri;
+        } else {
+            return name;
+        }
+    }
+    
     protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws
IOException,
             PortletException {
 

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=1350916&r1=1350915&r2=1350916&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
Sat Jun 16 12:51:27 2012
@@ -69,11 +69,11 @@
         <td>
             <!-- obr:refreshurl -->
             <span>
-                <a href="<portlet:actionURL><portlet:param name='uri' value='${repo.URI}'/><portlet:param
name='action' value='refreshurl'/></portlet:actionURL>">Refresh</a>&nbsp;
+                <a href="<portlet:actionURL><portlet:param name='repo.uri' value='${repo.URI}'/><portlet:param
name='repo.name' value='${repo.name}'/><portlet:param name='action' value='refreshurl'/></portlet:actionURL>">Refresh</a>&nbsp;
             </span>
             <!-- obr:removeurl -->
             <span>
-                <a href="<portlet:actionURL><portlet:param name='uri' value='${repo.URI}'/><portlet:param
name='action' value='removeurl'/></portlet:actionURL>">Remove</a>&nbsp;
+                <a href="<portlet:actionURL><portlet:param name='repo.uri' value='${repo.URI}'/><portlet:param
name='repo.name' value='${repo.name}'/><portlet:param name='action' value='removeurl'/></portlet:actionURL>">Remove</a>&nbsp;
             </span>
         </td>
       </tr>



Mime
View raw message