geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r701533 - in /geronimo/server/trunk/plugins/console/plugin-portlets/src/main: java/org/apache/geronimo/console/car/ webapp/WEB-INF/view/car/
Date Fri, 03 Oct 2008 21:06:59 GMT
Author: linsun
Date: Fri Oct  3 14:06:59 2008
New Revision: 701533

URL: http://svn.apache.org/viewvc?rev=701533&view=rev
Log:
GERONIMO-4336 some improvements to the addRepository page of the install plugin portlet

Modified:
    geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java
    geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
    geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ListHandler.java
    geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ViewPluginDownloadHandler.java
    geronimo/server/trunk/plugins/console/plugin-portlets/src/main/webapp/WEB-INF/view/car/addRepository.jsp

Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java?rev=701533&r1=701532&r2=701533&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java
(original)
+++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/AddRepositoryHandler.java
Fri Oct  3 14:06:59 2008
@@ -20,6 +20,7 @@
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.console.MultiPageModel;
 import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.crypto.encoders.Base64;
 import org.apache.geronimo.system.plugin.PluginRepositoryList;
 
 import javax.portlet.ActionRequest;
@@ -40,7 +41,7 @@
 import java.util.List;
 
 /**
- * Handler for the import export main screen.
+ * Handler for the add repository screen.
  *
  * @version $Rev$ $Date$
  */
@@ -62,6 +63,7 @@
             list.addAll(repo.getRepositories());
         }
         String error = request.getParameter("repoError");
+        
         if(error != null && !error.equals("")) {
             request.setAttribute("repoError", error);
         }
@@ -80,6 +82,9 @@
 
 
     private boolean addRepository(String repo, ActionRequest request, ActionResponse response)
throws IOException {
+        String userName = request.getParameter("username");
+        String password = request.getParameter("password");
+        
         repo = repo.trim();
         repo = repo.replaceAll(" ", "%20");
         if(!repo.endsWith("/")) {
@@ -112,24 +117,30 @@
             URL test = new URL(repo+"geronimo-plugins.xml");
             log.debug("Checking repository "+test);
             URLConnection urlConnection = test.openConnection();
+            
             if(urlConnection instanceof HttpURLConnection) {
                 HttpURLConnection con = (HttpURLConnection) urlConnection;
                 try {
+                    if (!isEmpty(userName)) {
+                        con.setRequestProperty("Authorization",
+                                "Basic " + new String(Base64.encode((userName + ":" + password).getBytes())));
+                    }
                     con.connect();
-                } catch (ConnectException e) {
-                    response.setRenderParameter("repoError", "Unable to connect to "+url+"
("+e.getMessage()+")");
-                    return false;
                 } catch (UnknownHostException e) {
                     response.setRenderParameter("repoError", "Unknown host: " + url.getHost());
                     return false;
+                } catch (Exception e) {
+                    response.setRenderParameter("repoError", "Unable to connect to " + url
+ " ("+e.getMessage()+")");
+                    return false;
                 }
                 int result = con.getResponseCode();
                 log.debug("Repository check response: "+result);
                 if(result == 404) {
-                    response.setRenderParameter("repoError", "Not a valid repository; no
plugin list found at "+test);
+                    response.setRenderParameter("repoError", "Not a valid repository. No
plugin list found at " + test);
                     return false;
                 } else if(result == 401) {
-                    log.warn("Unable to validate repository -- it requires authentication.
 Assuming you know what you're doing.");
+                    response.setRenderParameter("repoError", "Unable to validate repository
-- it requires authentication.  Please provide a valid username or password");
+                    return false;
                 } else if(result != 200) {
                     log.warn("Unexpected response code while validating repository ("+result+"
"+con.getResponseMessage()+").  Assuming you know what you're doing.");
                 }
@@ -141,14 +152,12 @@
                     in.read();
                     in.close();
                 } catch (IOException e) {
-                    response.setRenderParameter("repoError", "Not a valid repository; no
plugin list found at "+test);
+                    response.setRenderParameter("repoError", "Not a valid repository. No
plugin list found at "+test);
                     return false;
                 }
             }
-            //TODO fish these out of the request?
-            String userName = null;
-            String password = null;
-            lists.get(0).addUserRepository(url, userName, password);
+            
+            lists.get(0).addUserRepository(url, isEmpty(userName) ?null : userName , password);
             request.setAttribute("repository", repo);
             return true;
         }

Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java?rev=701533&r1=701532&r2=701533&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
(original)
+++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/BaseImportExportHandler.java
Fri Oct  3 14:06:59 2008
@@ -63,7 +63,7 @@
         super(mode, viewName);
     }
 
-    protected PluginListType getRepoPluginList(PortletRequest request, PluginInstaller pluginInstaller,
String repo, String user, String pass) throws IOException, PortletException {
+    protected PluginListType getRepoPluginList(PortletRequest request, PluginInstaller pluginInstaller,
String repo) throws IOException, PortletException {
         PortletSession session = request.getPortletSession(true);
         PluginListType list = (PluginListType) session.getAttribute(CONFIG_LIST_SESSION_KEY);
         String listRepo = (String) session.getAttribute(CONFIG_LIST_REPO_SESSION_KEY);

Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ListHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ListHandler.java?rev=701533&r1=701532&r2=701533&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ListHandler.java
(original)
+++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ListHandler.java
Fri Oct  3 14:06:59 2008
@@ -66,7 +66,7 @@
         String user = request.getParameter("repo-user");
         String pass = request.getParameter("repo-pass");
         String column = request.getParameter("column");
-        if(!loadFromRepository(request, repository, user, pass)) {
+        if(!loadFromRepository(request, repository)) {
             //todo: loading failed -- do something!
         }
         request.setAttribute("repository", repository);
@@ -79,12 +79,12 @@
         return getMode()+BEFORE_ACTION;
     }
 
-    private boolean loadFromRepository(RenderRequest request, String repository, String username,
String password) throws IOException, PortletException {
+    private boolean loadFromRepository(RenderRequest request, String repository) throws IOException,
PortletException {
         
         PluginInstaller pluginInstaller = ManagementHelper.getManagementHelper(request).getPluginInstaller();
 
         // try to reuse the catalog data if it was already downloaded
-        PluginListType data = getRepoPluginList(request, pluginInstaller, repository, username,
password);
+        PluginListType data = getRepoPluginList(request, pluginInstaller, repository);
         
         if(data == null || data.getPlugin() == null) {
             return false;

Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ViewPluginDownloadHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ViewPluginDownloadHandler.java?rev=701533&r1=701532&r2=701533&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ViewPluginDownloadHandler.java
(original)
+++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/java/org/apache/geronimo/console/car/ViewPluginDownloadHandler.java
Fri Oct  3 14:06:59 2008
@@ -72,7 +72,7 @@
         String user = request.getParameter("repo-user");
         String pass = request.getParameter("repo-pass");
 
-        PluginListType list = getRepoPluginList(request, pluginInstaller, repo, user, pass);
+        PluginListType list = getRepoPluginList(request, pluginInstaller, repo);
         PluginListType installList = getPluginsFromIds(configIds, list);
         List<PluginInfoBean> plugins = new ArrayList<PluginInfoBean>();
         for (PluginType pluginType: installList.getPlugin()) {
@@ -126,7 +126,7 @@
         String pass = request.getParameter("repo-pass");
         String[] configIds = request.getParameterValues("configId");
 
-        PluginListType list = getRepoPluginList(request, pluginInstaller, repo, user, pass);
+        PluginListType list = getRepoPluginList(request, pluginInstaller, repo);
         PluginListType installList = getPluginsFromIds(configIds, list);
 
         Object downloadKey = pluginInstaller.startInstall(installList, repo, false, user,
pass);

Modified: geronimo/server/trunk/plugins/console/plugin-portlets/src/main/webapp/WEB-INF/view/car/addRepository.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/plugin-portlets/src/main/webapp/WEB-INF/view/car/addRepository.jsp?rev=701533&r1=701532&r2=701533&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/plugin-portlets/src/main/webapp/WEB-INF/view/car/addRepository.jsp
(original)
+++ geronimo/server/trunk/plugins/console/plugin-portlets/src/main/webapp/WEB-INF/view/car/addRepository.jsp
Fri Oct  3 14:06:59 2008
@@ -46,7 +46,11 @@
 <form name="<portlet:namespace/>PluginForm" action="<portlet:actionURL/>">
     <input type="hidden" name="mode" value="addRepository-after" />
     <b><label for="<portlet:namespace/>newRepository"><fmt:message key="car.common.newRepository"
/></label>:</b> <input type="text" name="newRepository" id="<portlet:namespace/>newRepository"
size="40" maxlength="200" />
-    <br />
+    <br/>
+    <b><fmt:message key="car.index.optionalAuthentication"/>:</b>
+    <label for="<portlet:namespace/>username"><fmt:message key="consolebase.common.user"/></label>:
<input type="text" name="username" id="<portlet:namespace/>username" value="${repouser}"
size="12" maxlength="200"/>
+    <label for="<portlet:namespace/>password"><fmt:message key="consolebase.common.password"/></label>:
<input type="password" name="password" id="<portlet:namespace/>password" value="${repopass}"
size="12" maxlength="200"/>
+    <br/>
     <c:if test="${!empty repoError}">
       <p><font color="red">${repoError}</font></p>
     </c:if>



Mime
View raw message