geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r396212 - in /geronimo/branches/1.1: applications/console-standard/src/java/org/apache/geronimo/console/ajax/ applications/console-standard/src/java/org/apache/geronimo/console/car/ applications/console-standard/src/webapp/WEB-INF/view/ajax...
Date Sun, 23 Apr 2006 03:46:12 GMT
Author: ammulder
Date: Sat Apr 22 20:46:10 2006
New Revision: 396212

URL: http://svn.apache.org/viewcvs?rev=396212&view=rev
Log:
Fix progress bar for plugin installer
 - works on Safari
 - directs to a new page and shows progress from there (doesn't hang
   while submitting)
 - Portlet-friendly (or friendlier)
This probably means that the download database driver page needs some
  attention

Added:
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadStatusHandler.java
    geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/downloadStatus.jsp
Modified:
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/ajax/ProgressInfo.java
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java
    geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/ajax/progressbar.jsp
    geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp
    geronimo/branches/1.1/etc/project.properties

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/ajax/ProgressInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/ajax/ProgressInfo.java?rev=396212&r1=396211&r2=396212&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/ajax/ProgressInfo.java
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/ajax/ProgressInfo.java
Sat Apr 22 20:46:10 2006
@@ -23,8 +23,9 @@
     private int progressPercent = -1;
     private String mainMessage;
     private String subMessage;
+    private boolean finished;
 
-	public int getProgressPercent() {
+    public int getProgressPercent() {
 		return progressPercent;
 	}
 
@@ -47,5 +48,12 @@
 	public void setSubMessage(String subMessage) {
 		this.subMessage = subMessage;
 	}
-    
+
+    public boolean isFinished() {
+        return finished;
+    }
+
+    public void setFinished(boolean finished) {
+        this.finished = finished;
+    }
 }

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java?rev=396212&r1=396211&r2=396212&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
Sat Apr 22 20:46:10 2006
@@ -25,9 +25,11 @@
  */
 public abstract class BaseImportExportHandler extends MultiPageAbstractHandler {
     protected static final String CONFIG_LIST_SESSION_KEY = "console.plugins.ConfigurationList";
+    protected static final String DOWNLOAD_RESULTS_SESSION_KEY = "console.plugins.DownloadResults";
     protected static final String INDEX_MODE = "index";
     protected static final String LIST_MODE = "list";
     protected static final String DOWNLOAD_MODE = "download";
+    protected static final String DOWNLOAD_STATUS_MODE = "downloadStatus";
     protected static final String RESULTS_MODE = "results";
     protected static final String CONFIGURE_EXPORT_MODE = "configure";
     protected static final String CONFIRM_EXPORT_MODE = "confirm";

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java?rev=396212&r1=396211&r2=396212&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java
Sat Apr 22 20:46:10 2006
@@ -124,56 +124,50 @@
             ConfigurationInstaller configInstaller = PortletManager.getCurrentServer(request).getConfigurationInstaller();

             Object downloadKey = configInstaller.startInstall(installList, user, pass);
             ProgressInfo progressInfo = new ProgressInfo();
-            request.getPortletSession().setAttribute(ProgressInfo.PROGRESS_INFO_KEY, progressInfo,
PortletSession.APPLICATION_SCOPE);
-            DownloadResults results;
-            while (true) {
-            	results = configInstaller.checkOnInstall(downloadKey);
-            	progressInfo.setMainMessage(results.getCurrentMessage());
-            	progressInfo.setProgressPercent(results.getCurrentFilePercent());
-            	if (results.isFinished() || results.isFailed()) {
-                	break;
-            	} else {
-            		try { Thread.sleep(1000); } catch (InterruptedException e) {
-                        log.error("Download monitor thread interrupted", e);
-					}
-            	}
-            }
-            if(results.isFailed()) {
-                throw new PortletException("Unable to install configuration", results.getFailure());
-            }
-            List dependencies = new ArrayList();
-            for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
-                Artifact uri = results.getDependenciesInstalled()[i];
-                dependencies.add(new InstallResults(uri.toString(), "installed"));
-            }
-            for (int i = 0; i < results.getDependenciesPresent().length; i++) {
-                Artifact uri = results.getDependenciesPresent()[i];
-                dependencies.add(new InstallResults(uri.toString(), "already present"));
-            }
-            request.getPortletSession(true).setAttribute("car.install.results", dependencies);
+            request.getPortletSession(true).setAttribute(ProgressInfo.PROGRESS_INFO_KEY,
progressInfo, PortletSession.APPLICATION_SCOPE);
+            // Kick off the download monitoring
+            new Thread(new Installer(configInstaller, downloadKey, progressInfo, request.getPortletSession(true))).start();
+
             response.setRenderParameter("configId", configId);
             response.setRenderParameter("repository", repo);
             if(!isEmpty(user)) response.setRenderParameter("repo-user", user);
             if(!isEmpty(pass)) response.setRenderParameter("repo-pass", pass);
         }
-        return RESULTS_MODE+BEFORE_ACTION;
+        return DOWNLOAD_STATUS_MODE+BEFORE_ACTION;
     }
 
-    public static class InstallResults implements Serializable {
-        private String name;
-        private String action;
+    public static class Installer implements Runnable {
+        private ConfigurationInstaller configInstaller;
+        private Object downloadKey;
+        private ProgressInfo progressInfo;
+        private PortletSession session;
 
-        public InstallResults(String name, String action) {
-            this.name = name;
-            this.action = action;
+        public Installer(ConfigurationInstaller configInstaller, Object downloadKey, ProgressInfo
progressInfo, PortletSession session) {
+            this.configInstaller = configInstaller;
+            this.downloadKey = downloadKey;
+            this.progressInfo = progressInfo;
+            this.session = session;
         }
 
-        public String getName() {
-            return name;
-        }
+        public void run() {
+            DownloadResults results;
 
-        public String getAction() {
-            return action;
+            while (true) {
+            	results = configInstaller.checkOnInstall(downloadKey);
+            	progressInfo.setMainMessage(results.getCurrentMessage());
+            	progressInfo.setProgressPercent(results.getCurrentFilePercent());
+                progressInfo.setFinished(results.isFinished());
+                log.info(progressInfo.getMainMessage());
+                if (results.isFinished()) {
+                    log.info("Installation finished");
+                    session.setAttribute(DOWNLOAD_RESULTS_SESSION_KEY, results);
+                    break;
+            	} else {
+            		try { Thread.sleep(1000); } catch (InterruptedException e) {
+                        log.error("Download monitor thread interrupted", e);
+					}
+            	}
+            }
         }
     }
 }

Added: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadStatusHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadStatusHandler.java?rev=396212&view=auto
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadStatusHandler.java
(added)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadStatusHandler.java
Sat Apr 22 20:46:10 2006
@@ -0,0 +1,113 @@
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed 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.car;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletSession;
+import javax.security.auth.login.FailedLoginException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.console.MultiPageModel;
+import org.apache.geronimo.console.ajax.ProgressInfo;
+import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.system.configuration.ConfigurationMetadata;
+import org.apache.geronimo.system.configuration.ConfigurationList;
+import org.apache.geronimo.system.configuration.ConfigurationInstaller;
+import org.apache.geronimo.system.configuration.DownloadResults;
+import org.apache.geronimo.kernel.repository.Artifact;
+
+/**
+ * Handler for the initial download screen.
+ *
+ * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
+ */
+public class DownloadStatusHandler extends BaseImportExportHandler {
+    private final static Log log = LogFactory.getLog(DownloadStatusHandler.class);
+
+    public DownloadStatusHandler() {
+        super(DOWNLOAD_STATUS_MODE, "/WEB-INF/view/car/downloadStatus.jsp");
+    }
+
+    public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel
model) throws PortletException, IOException {
+        return getMode();
+    }
+
+    public void renderView(RenderRequest request, RenderResponse response, MultiPageModel
model) throws PortletException, IOException {
+        String configId = request.getParameter("configId");
+        String repo = request.getParameter("repository");
+        String user = request.getParameter("repo-user");
+        String pass = request.getParameter("repo-pass");
+        request.setAttribute("configId", configId);
+        request.setAttribute("repository", repo);
+        request.setAttribute("repouser", user);
+        request.setAttribute("repopass", pass);
+    }
+
+    public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel
model) throws PortletException, IOException {
+        String repo = request.getParameter("repository");
+        String user = request.getParameter("repo-user");
+        String pass = request.getParameter("repo-pass");
+        String configId = request.getParameter("configId");
+
+        DownloadResults results = (DownloadResults) request.getPortletSession(true).getAttribute(DOWNLOAD_RESULTS_SESSION_KEY);
+        if(results.isFailed()) {
+            throw new PortletException("Unable to install configuration", results.getFailure());
+        }
+        List dependencies = new ArrayList();
+        for (int i = 0; i < results.getDependenciesInstalled().length; i++) {
+            Artifact uri = results.getDependenciesInstalled()[i];
+            dependencies.add(new InstallResults(uri.toString(), "installed"));
+        }
+        for (int i = 0; i < results.getDependenciesPresent().length; i++) {
+            Artifact uri = results.getDependenciesPresent()[i];
+            dependencies.add(new InstallResults(uri.toString(), "already present"));
+        }
+        request.getPortletSession(true).setAttribute("car.install.results", dependencies);
+
+        response.setRenderParameter("configId", configId);
+        response.setRenderParameter("repository", repo);
+        if(!isEmpty(user)) response.setRenderParameter("repo-user", user);
+        if(!isEmpty(pass)) response.setRenderParameter("repo-pass", pass);
+        return RESULTS_MODE+BEFORE_ACTION;
+    }
+
+    public static class InstallResults implements Serializable {
+        private String name;
+        private String action;
+
+        public InstallResults(String name, String action) {
+            this.name = name;
+            this.action = action;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getAction() {
+            return action;
+        }
+    }
+}

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java?rev=396212&r1=396211&r2=396212&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java
Sat Apr 22 20:46:10 2006
@@ -37,6 +37,7 @@
         addHelper(new ResultsHandler(), config);
         addHelper(new ExportConfigHandler(), config);
         addHelper(new ExportHandler(), config);
+        addHelper(new DownloadStatusHandler(), config);
     }
 
     protected String getModelJSPVariableName() {

Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/ajax/progressbar.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/ajax/progressbar.jsp?rev=396212&r1=396211&r2=396212&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/ajax/progressbar.jsp
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/ajax/progressbar.jsp
Sat Apr 22 20:46:10 2006
@@ -1,52 +1,69 @@
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<portlet:defineObjects/>
 <% String dwrForwarderServlet = org.apache.geronimo.console.util.PortletManager.getConsoleFrameworkServletPath(request)
+ "/../dwr"; %>
 <script type='text/javascript' src='<%= dwrForwarderServlet %>/interface/ProgressMonitor.js'></script>
 <script type='text/javascript' src='<%= dwrForwarderServlet %>/engine.js'></script>
 <script type='text/javascript' src='<%= dwrForwarderServlet %>/util.js'></script>
 
-<script>
-function refreshProgress()
+<script type="text/javascript">
+DWREngine.setErrorHandler(<portlet:namespace/>onError);
+function <portlet:namespace/>refreshProgress()
 {
-    ProgressMonitor.getProgressInfo(updateProgress);
+    metadata = {};
+    metadata.callback=<portlet:namespace/>updateProgress;
+    metadata.errorHandler=<portlet:namespace/>onError;
+    ProgressMonitor.getProgressInfo(metadata);
 }
 
-function updateProgress(progressInfo)
+function <portlet:namespace/>onError() {
+    DWRUtil.setValue("<portlet:namespace/>ErrorArea", 'I had a problem!');
+}
+
+function <portlet:namespace/>updateProgress(progressInfo)
 {
     // get the bean values from DWR
     var progressPercent = progressInfo.progressPercent;
     var mainMessage = progressInfo.mainMessage;
     var subMessage = progressInfo.subMessage;
+    var finished = progressInfo.finished;
 
     // set the bean values in the HTML document
     if (mainMessage != null) {
-	    document.getElementById('progressMeterMainMessage').innerHTML = mainMessage;
+	    document.getElementById('<portlet:namespace/>progressMeterMainMessage').innerHTML
= mainMessage;
     }
     if (subMessage != null) {
-	    document.getElementById('progressMeterSubMessage').innerHTML = subMessage;
+	    document.getElementById('<portlet:namespace/>progressMeterSubMessage').innerHTML
= subMessage;
     }
     if (progressPercent > -1) {
-       document.getElementById('progressMeterShell').style.display = 'block';
-       document.getElementById('progressMeterBar').style.width = parseInt(progressPercent
* 3.5) + 'px';
+       document.getElementById('<portlet:namespace/>progressMeterShell').style.display
= 'block';
+       document.getElementById('<portlet:namespace/>progressMeterBar').style.width
= parseInt(progressPercent * 3.5) + 'px';
+    }
+    if(finished) {
+        document.forms['<portlet:namespace/>ContinueForm'].submit();
+    } else {
+        window.setTimeout('<portlet:namespace/>refreshProgress()', 1000);
     }
-    window.setTimeout('refreshProgress()', 1000);
     return true;
 }
 
-function startProgress()
+function <portlet:namespace/>startProgress()
 {
-    document.getElementById('progressMeter').style.display = 'block';
-    document.getElementById('progressMeterMainMessage').innerHTML = 'Processing...';
-    window.setTimeout("refreshProgress()", 1000);
+    document.getElementById('<portlet:namespace/>progressMeterMainMessage').innerHTML
= 'Processing...';
+    document.getElementById('<portlet:namespace/>progressMeter').style.display = 'block';
+    window.setTimeout("<portlet:namespace/>refreshProgress()", 1000);
     return true;
 }
 </script>
 
-<div id="progressMeter" style="display: none; padding-top: 5px;">
+<div id="<portlet:namespace/>progressMeter" style="display: none; padding-top: 5px;">
     <br/>
     <div>
-        <div id="progressMeterMainMessage"></div>
-        <div id="progressMeterSubMessage"></div>
-        <div id="progressMeterShell" style="display: none; width: 350px; height: 20px;
border: 1px inset; background: #eee;">
-            <div id="progressMeterBar" style="width: 0; height: 20px; border-right: 1px
solid #444; background: #9ACB34;"></div>
+        <div id="<portlet:namespace/>progressMeterMainMessage"></div>
+        <div id="<portlet:namespace/>progressMeterSubMessage"></div>
+        <div id="<portlet:namespace/>progressMeterShell" style="display: none; width:
350px; height: 20px; border: 1px inset; background: #eee;">
+            <div id="<portlet:namespace/>progressMeterBar" style="width: 0; height:
20px; border-right: 1px solid #444; background: #9ACB34;"></div>
         </div>
     </div>
 </div>
+
+<div id="<portlet:namespace/>ErrorArea"></div>

Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp?rev=396212&r1=396211&r2=396212&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp
Sat Apr 22 20:46:10 2006
@@ -14,7 +14,7 @@
 </c:forEach>
 </ul>
 
-<form name="<portlet:namespace/>PluginForm" action="<portlet:actionURL/>"
onsubmit="startProgress()">
+<form name="<portlet:namespace/>PluginForm" action="<portlet:actionURL/>">
     <input type="hidden" name="file" value="${file}" />
     <input type="hidden" name="configId" value="${configId}" />
     <input type="hidden" name="mode" value="download-after" />
@@ -24,7 +24,5 @@
     <input type="hidden" name="proceed" value="true" />
     <input type="submit" value="Install Plugin" />
 </form>
-
-<jsp:include flush="true" page="../ajax/progressbar.jsp"/>
 
 <p><a href="<portlet:actionURL portletMode="view"><portlet:param name="mode"
value="index-before" /></portlet:actionURL>">Cancel</a></p>

Added: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/downloadStatus.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/downloadStatus.jsp?rev=396212&view=auto
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/downloadStatus.jsp
(added)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/car/downloadStatus.jsp
Sat Apr 22 20:46:10 2006
@@ -0,0 +1,24 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<portlet:defineObjects/>
+
+<p>Processing ${configId}...</p>
+
+
+<form name="<portlet:namespace/>ContinueForm" action="<portlet:actionURL/>">
+    <input type="hidden" name="mode" value="downloadStatus-after" />
+    <input type="hidden" name="configId" value="${configId}" />
+    <input type="hidden" name="repository" value="${repository}" />
+    <input type="hidden" name="repo-user" value="${repouser}" />
+    <input type="hidden" name="repo-pass" value="${repopass}" />
+</form>
+
+<jsp:include flush="true" page="../ajax/progressbar.jsp"/>
+
+<script type="text/javascript">
+    <portlet:namespace/>startProgress();
+</script>
+<%--
+<p><a href="<portlet:actionURL portletMode="view"><portlet:param name="mode"
value="index-before" /></portlet:actionURL>">Cancel</a></p>
+--%>
\ No newline at end of file

Modified: geronimo/branches/1.1/etc/project.properties
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/etc/project.properties?rev=396212&r1=396211&r2=396212&view=diff
==============================================================================
--- geronimo/branches/1.1/etc/project.properties (original)
+++ geronimo/branches/1.1/etc/project.properties Sat Apr 22 20:46:10 2006
@@ -150,7 +150,7 @@
 daytrader_version=1.1-SNAPSHOT
 derby_version=10.1.1.0
 dom4j_version=1.4
-dwr_version=1.0
+dwr_version=1.1.1
 eclipse_compiler_version=3.0.1
 howl_version=0.1.11
 #security:



Mime
View raw message