Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 73789 invoked from network); 24 Mar 2006 23:02:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Mar 2006 23:02:13 -0000 Received: (qmail 28711 invoked by uid 500); 24 Mar 2006 23:02:13 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 28685 invoked by uid 500); 24 Mar 2006 23:02:13 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 28674 invoked by uid 99); 24 Mar 2006 23:02:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Mar 2006 15:02:13 -0800 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 24 Mar 2006 15:02:10 -0800 Received: (qmail 73158 invoked by uid 65534); 24 Mar 2006 23:01:50 -0000 Message-ID: <20060324230150.73155.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r388671 - in /geronimo/trunk: applications/console-framework/src/webapp/WEB-INF/data/ applications/console-standard/src/java/org/apache/geronimo/console/ applications/console-standard/src/java/org/apache/geronimo/console/car/ applications/c... Date: Fri, 24 Mar 2006 23:01:46 -0000 To: scm@geronimo.apache.org From: ammulder@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: ammulder Date: Fri Mar 24 15:01:45 2006 New Revision: 388671 URL: http://svn.apache.org/viewcvs?rev=388671&view=rev Log: Console can export and download configuration CARs Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java (with props) geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/CARExportServlet.java (with props) geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java (with props) geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java (with props) geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/IndexHandler.java (with props) geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java (with props) geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ResultsHandler.java (with props) geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp (with props) geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/index.jsp (with props) geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp (with props) geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/results.jsp (with props) Modified: geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/pageregistry.xml geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/portletentityregistry.xml geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/MultiPagePortlet.java geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/portlet.xml geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/web.xml geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java Modified: geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/pageregistry.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/pageregistry.xml?rev=388671&r1=388670&r2=388671&view=diff ============================================================================== --- geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/pageregistry.xml (original) +++ geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/pageregistry.xml Fri Mar 24 15:01:45 2006 @@ -440,6 +440,21 @@ + + + Import/Export + ico_list_16x16.gif Import and export configurations for this server + + + + + + + + + + + Modified: geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/portletentityregistry.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/portletentityregistry.xml?rev=388671&r1=388670&r2=388671&view=diff ============================================================================== --- geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/portletentityregistry.xml (original) +++ geronimo/trunk/applications/console-framework/src/webapp/WEB-INF/data/portletentityregistry.xml Fri Mar 24 15:01:45 2006 @@ -145,5 +145,8 @@ console-standard.Keystores + + console-standard.ImportExport + Modified: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/MultiPagePortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/MultiPagePortlet.java?rev=388671&r1=388670&r2=388671&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/MultiPagePortlet.java (original) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/MultiPagePortlet.java Fri Mar 24 15:01:45 2006 @@ -123,7 +123,9 @@ if(mode != null) { actionResponse.setRenderParameter(MODE_KEY, mode); } - model.save(actionResponse); + if(model != null) { + model.save(actionResponse); + } } protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { @@ -158,8 +160,8 @@ } protected String getDefaultMode() { - if(helpers.containsKey("list")) return "list"; if(helpers.containsKey("index")) return "index"; + if(helpers.containsKey("list")) return "list"; return null; } Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java (added) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java Fri Mar 24 15:01:45 2006 @@ -0,0 +1,55 @@ +/** + * + * Copyright 2005 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 org.apache.geronimo.console.MultiPageAbstractHandler; +import org.apache.geronimo.console.MultiPageModel; +import org.apache.geronimo.console.keystores.BaseKeystoreHandler; +import org.apache.geronimo.security.keystore.KeystoreInstance; +import org.apache.geronimo.util.CertificateUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.portlet.PortletRequest; +import javax.portlet.ActionResponse; +import java.io.Serializable; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.io.FileInputStream; +import java.util.Map; +import java.util.HashMap; +import java.util.Collection; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; + +/** + * The base class for all handlers for this portlet + * + * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ + */ +public abstract class BaseImportExportHandler extends MultiPageAbstractHandler { + private final static Log log = LogFactory.getLog(BaseImportExportHandler.class); + 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 RESULTS_MODE = "results"; + + protected BaseImportExportHandler(String mode, String viewName) { + super(mode, viewName); + } +} Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/BaseImportExportHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/CARExportServlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/CARExportServlet.java?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/CARExportServlet.java (added) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/CARExportServlet.java Fri Mar 24 15:01:45 2006 @@ -0,0 +1,63 @@ +/** + * + * Copyright 2005 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 org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.KernelRegistry; +import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.gbean.GBeanQuery; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletException; +import javax.management.ObjectName; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Set; +import java.util.Iterator; + +/** + * Servlet that lets you download a CAR from the repository + * + * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ + */ +public class CARExportServlet extends HttpServlet { + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String configId = request.getParameter("configId"); + if(configId == null) { + throw new ServletException("No configId specified for CAR download"); + } + Kernel kernel = KernelRegistry.getSingleKernel(); + Set set = kernel.listGBeans(new GBeanQuery(null, ConfigurationStore.class.getName())); + for (Iterator it = set.iterator(); it.hasNext();) { + ObjectName name = (ObjectName) it.next(); + if(name.getKeyProperty(NameFactory.J2EE_NAME).equals("Local")) { + response.setContentType("application/zip"); + try { + kernel.invoke(name, "exportConfiguration", new Object[]{configId, response.getOutputStream()}, new String[]{String.class.getName(), OutputStream.class.getName()}); + return; + } catch (Exception e) { + throw new IOException("Unable to write ZIP file: "+e.getMessage()); + } + } + } + response.setContentType("text/html"); + response.getWriter().println("

Error: no LocalConfigStore found in kernel

"); + } +} Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/CARExportServlet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java (added) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java Fri Mar 24 15:01:45 2006 @@ -0,0 +1,231 @@ +/** + * + * Copyright 2005 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 org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.console.MultiPageModel; +import org.apache.geronimo.console.util.PortletManager; +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.gbean.GBeanQuery; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; +import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.KernelRegistry; +import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.repository.Repository; +import org.apache.geronimo.kernel.repository.WriteableRepository; + +import javax.management.ObjectName; +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +/** + * Handler for the initial download screen. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ + */ +public class DownloadCARHandler extends BaseImportExportHandler { + private final static Log log = LogFactory.getLog(DownloadCARHandler.class); + + public DownloadCARHandler() { + super(DOWNLOAD_MODE, "/WEB-INF/view/car/download.jsp"); + } + + public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { + String configId = request.getParameter("configId"); + String repo = request.getParameter("repository"); + if(!repo.endsWith("/")) { + repo += "/"; + } + String url = getURL(configId, repo); + File file = File.createTempFile("geronimo-download", "." + configId.substring(configId.lastIndexOf("/")+1)); + file.deleteOnExit(); + downloadFile(url, file); + response.setRenderParameter("configId", configId); + response.setRenderParameter("file", file.getAbsolutePath()); + response.setRenderParameter("repository", repo); + + return getMode(); + } + + public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException { + String configId = request.getParameter("configId"); + String repo = request.getParameter("repository"); + File file = new File(request.getParameter("file")); + ZipFile zip = new ZipFile(file); + try { + ZipEntry entry = zip.getEntry("META-INF/config.ser"); + ObjectInputStream serIn = new ObjectInputStream(zip.getInputStream(entry)); + GBeanData config = new GBeanData(); + config.readExternal(serIn); + URI[] parentIds = (URI[]) config.getAttribute("parentId"); + List dependencies = (List) config.getAttribute("dependencies"); + request.setAttribute("file", file.getAbsolutePath()); + request.setAttribute("configId", configId); + request.setAttribute("parents", parentIds); + request.setAttribute("dependencies", dependencies); + request.setAttribute("repository", repo); + } catch (ClassNotFoundException e) { + throw new PortletException("Unable to deserialize GBeanData", e); + } finally { + zip.close(); + } + } + + public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { + String repo = request.getParameter("repository"); + boolean proceed = Boolean.valueOf(request.getParameter("proceed")).booleanValue(); + if(proceed) { + String configId = request.getParameter("configId"); + File file = new File(request.getParameter("file")); + + WriteableRepository[] repos = PortletManager.getWritableRepositories(request); + if(repos.length < 1) { + throw new PortletException("No writeable repository available in kernel"); + } + List configs = new ArrayList(); + List deps = new ArrayList(); + downloadConfiguration(file, repos[0], repo, configs, deps); + request.getPortletSession(true).setAttribute("car.install.configurations", configs); + request.getPortletSession(true).setAttribute("car.install.dependencies", deps); + response.setRenderParameter("configId", configId); + } + return RESULTS_MODE+BEFORE_ACTION; + } + + private void downloadConfiguration(File file, WriteableRepository repo, String repoURL, List configResults, List dependencyResults) throws IOException, PortletException { + Kernel kernel = KernelRegistry.getSingleKernel(); + Set set = kernel.listGBeans(new GBeanQuery(null, ConfigurationStore.class.getName())); + ConfigurationStore stores[] = new ConfigurationStore[set.size()]; + int index = 0; + for (Iterator it = set.iterator(); it.hasNext(); ++index) { + ObjectName name = (ObjectName) it.next(); + stores[index] = (ConfigurationStore) kernel.getProxyManager().createProxy(name, ConfigurationStore.class); + } + ZipFile zip = new ZipFile(file); + try { + ZipEntry entry = zip.getEntry("META-INF/config.ser"); + ObjectInputStream serIn = new ObjectInputStream(zip.getInputStream(entry)); + GBeanData config = new GBeanData(); + config.readExternal(serIn); + URI[] parentIds = (URI[]) config.getAttribute("parentId"); + List dependencies = (List) config.getAttribute("dependencies"); + // Download the dependencies + for (int i = 0; i < dependencies.size(); i++) { + URI dep = (URI) dependencies.get(i); + if(((Repository)repo).hasURI(dep)) { + dependencyResults.add(new DownloadResults(dep.toString(), "already present")); + continue; + } + String url = getURL(dep.toString(), repoURL); + log.info("Downloading "+url+" to local repository"); + repo.copyToRepository(new URL(url).openStream(), dep, null); + dependencyResults.add(new DownloadResults(dep.toString(), "downloaded and installed")); + } + // Download the parents + parents: + for (int i = 0; i < parentIds.length; i++) { + String id = parentIds[i].toString(); + URI uri = new URI(id); + for (int j = 0; j < stores.length; j++) { + ConfigurationStore store = stores[j]; + if(store.containsConfiguration(uri)) { + configResults.add(new DownloadResults(uri.toString(), "already present")); + continue parents; + } + } + File next = File.createTempFile("geronimo-download", "." + id.substring(id.lastIndexOf("/")+1)); + file.deleteOnExit(); + String url = getURL(id, repoURL); + downloadFile(url, next); + downloadConfiguration(next, repo, repoURL, configResults, dependencyResults); + } + // Install the configuration + for (Iterator it = set.iterator(); it.hasNext();) { + ObjectName name = (ObjectName) it.next(); + if(name.getKeyProperty(NameFactory.J2EE_NAME).equals("Local")) { + try { + URI uri = (URI)kernel.invoke(name, "install", new Object[]{file.toURL()}, new String[]{URL.class.getName()}); + configResults.add(new DownloadResults(uri.toString(), "downloaded and installed")); + } catch (Exception e) { + throw new IOException("Unable to write ZIP file: "+e.getMessage()); + } + } + } + } catch (URISyntaxException e) { + throw new PortletException("Unable to process parent configurations", e); + } catch (ClassNotFoundException e) { + throw new PortletException("Unable to deserialize GBeanData", e); + } finally { + zip.close(); + } + } + + private String getURL(String configId, String baseRepositoryURL) { + String[] parts = configId.split("/"); + return baseRepositoryURL+parts[0]+"/"+parts[3]+"s/"+parts[1]+"-"+parts[2]+"."+parts[3]; + } + + private void downloadFile(String url, File target) throws IOException { + log.info("Downloading "+url+" to "+target.getAbsolutePath()); + byte[] buf = new byte[10240]; + InputStream in = new URL(url).openStream(); + FileOutputStream out = new FileOutputStream(target); + int count; + while((count = in.read(buf)) > -1) { + out.write(buf, 0, count); + } + in.close(); + out.close(); + } + + public static class DownloadResults implements Serializable { + private String name; + private String action; + + public DownloadResults(String name, String action) { + this.name = name; + this.action = action; + } + + public String getName() { + return name; + } + + public String getAction() { + return action; + } + } +} Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/DownloadCARHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java (added) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java Fri Mar 24 15:01:45 2006 @@ -0,0 +1,47 @@ +/** + * + * Copyright 2005 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 org.apache.geronimo.console.MultiPagePortlet; +import org.apache.geronimo.console.MultiPageModel; + +import javax.portlet.PortletRequest; +import javax.portlet.PortletConfig; +import javax.portlet.PortletException; + +/** + * Portlet that can import and export CAR files + * + * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ + */ +public class ImportExportPortlet extends MultiPagePortlet { + public void init(PortletConfig config) throws PortletException { + super.init(config); + addHelper(new IndexHandler(), config); + addHelper(new ListHandler(), config); + addHelper(new DownloadCARHandler(), config); + addHelper(new ResultsHandler(), config); + } + + protected String getModelJSPVariableName() { + return "model"; + } + + protected MultiPageModel getModel(PortletRequest request) { + return null; + } +} Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ImportExportPortlet.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/IndexHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/IndexHandler.java?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/IndexHandler.java (added) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/IndexHandler.java Fri Mar 24 15:01:45 2006 @@ -0,0 +1,53 @@ +/** + * + * Copyright 2005 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 org.apache.geronimo.console.MultiPageModel; +import org.apache.geronimo.console.util.PortletManager; +import org.apache.geronimo.kernel.config.ConfigurationInfo; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import java.io.IOException; + +/** + * Handler for the import export main screen. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ + */ +public class IndexHandler extends BaseImportExportHandler { + public IndexHandler() { + super(INDEX_MODE, "/WEB-INF/view/car/index.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 { + ConfigurationInfo[] configs = PortletManager.getConfigurations(request, null, false); + request.setAttribute("configurations", configs); + } + + public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { + request.setAttribute("repository", request.getParameter("repository")); + return LIST_MODE+BEFORE_ACTION; + } +} Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/IndexHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java (added) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java Fri Mar 24 15:01:45 2006 @@ -0,0 +1,138 @@ +/** + * + * Copyright 2005 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 org.apache.geronimo.console.keystores.BaseKeystoreHandler; +import org.apache.geronimo.console.MultiPageModel; +import org.apache.geronimo.console.util.PortletManager; +import org.apache.geronimo.security.keystore.KeystoreManager; +import org.apache.geronimo.kernel.config.ConfigurationInfo; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +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 java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.net.URL; +import java.util.Properties; +import java.util.Map; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ArrayList; +import java.util.Set; +import java.util.HashSet; + +/** + * Handler for the import export list screen. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ + */ +public class ListHandler extends BaseImportExportHandler { + private final static Log log = LogFactory.getLog(ListHandler.class); + + public ListHandler() { + super(LIST_MODE, "/WEB-INF/view/car/list.jsp"); + } + + public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { + String repository = (String) request.getAttribute("repository"); + if(repository == null || repository.equals("")) { + return INDEX_MODE+BEFORE_ACTION; + } + response.setRenderParameter("repository", repository); + return getMode(); + } + + public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException { + String repository = request.getParameter("repository"); + loadFromRepository(request, repository); + request.setAttribute("repository", repository); + } + + public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { + return getMode()+BEFORE_ACTION; + } + + private void loadFromRepository(RenderRequest request, String repository) throws IOException { + if(!repository.endsWith("/")) { + repository = repository+"/"; + } + URL url = new URL(repository+"geronimo-configurations.properties"); + Set set = new HashSet(); + ConfigurationInfo[] installed = PortletManager.getConfigurations(request, null, false); + for (int i = 0; i < installed.length; i++) { + ConfigurationInfo info = installed[i]; + set.add(info.getConfigID().toString()); + } + InputStream in = url.openStream(); + Properties props = new Properties(); + props.load(in); + in.close(); + Map results = new HashMap(); + for (Iterator it = props.keySet().iterator(); it.hasNext();) { + String key = (String) it.next(); + int pos = key.indexOf('.'); + String type = key.substring(0, pos); + List values = (List) results.get(type); + if(values == null) { + values = new ArrayList(); + results.put(type, values); + } + String configId = key.substring(pos + 1); + values.add(new RepositoryEntry(configId, props.getProperty(key), set.contains(configId))); + } + request.setAttribute("categories", results); + } + + public static class RepositoryEntry implements Serializable { + private String configId; + private String name; + private boolean installed; + private String version; + + public RepositoryEntry(String configId, String name, boolean installed) { + this.configId = configId; + this.name = name; + this.installed = installed; + String[] parts = configId.split("/"); + version = parts[2]; + } + + public String getConfigId() { + return configId; + } + + public String getName() { + return name; + } + + public boolean isInstalled() { + return installed; + } + + public String getVersion() { + return version; + } + } +} Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ListHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ResultsHandler.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ResultsHandler.java?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ResultsHandler.java (added) +++ geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ResultsHandler.java Fri Mar 24 15:01:45 2006 @@ -0,0 +1,100 @@ +/** + * + * Copyright 2005 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 org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.console.MultiPageModel; +import org.apache.geronimo.console.util.PortletManager; +import org.apache.geronimo.gbean.GBeanData; +import org.apache.geronimo.gbean.GBeanQuery; +import org.apache.geronimo.kernel.repository.WriteableRepository; +import org.apache.geronimo.kernel.repository.Repository; +import org.apache.geronimo.kernel.Kernel; +import org.apache.geronimo.kernel.KernelRegistry; +import org.apache.geronimo.kernel.config.ConfigurationStore; +import org.apache.geronimo.kernel.config.ConfigurationManager; +import org.apache.geronimo.kernel.config.ConfigurationUtil; +import org.apache.geronimo.kernel.config.NoSuchConfigException; +import org.apache.geronimo.kernel.config.InvalidConfigException; +import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; + +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletException; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.management.ObjectName; +import java.io.IOException; +import java.io.File; +import java.io.ObjectInputStream; +import java.io.InputStream; +import java.io.FileOutputStream; +import java.io.Serializable; +import java.util.zip.ZipFile; +import java.util.zip.ZipEntry; +import java.util.List; +import java.util.ArrayList; +import java.util.Set; +import java.util.Iterator; +import java.net.URI; +import java.net.URL; +import java.net.URISyntaxException; + +/** + * Handler for the import results screen. + * + * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $ + */ +public class ResultsHandler extends BaseImportExportHandler { + private final static Log log = LogFactory.getLog(ResultsHandler.class); + + public ResultsHandler() { + super(RESULTS_MODE, "/WEB-INF/view/car/results.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"); + request.setAttribute("configId", configId); + List configs = (List) request.getPortletSession(true).getAttribute("car.install.configurations"); + List deps = (List) request.getPortletSession(true).getAttribute("car.install.dependencies"); + request.setAttribute("dependencies", deps); + request.setAttribute("configurations", configs); + } + + public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { + String configId = request.getParameter("configId"); + try { + ConfigurationManager mgr = ConfigurationUtil.getConfigurationManager(KernelRegistry.getSingleKernel()); + List list = mgr.loadRecursive(new URI(configId)); + for (Iterator it = list.iterator(); it.hasNext();) { + URI uri = (URI) it.next(); + mgr.loadGBeans(uri); + mgr.start(uri); + } + return LIST_MODE+BEFORE_ACTION; + } catch (Exception e) { + log.error("Unable to start configuration "+configId, e); + response.setRenderParameter("configId", configId); + return getMode()+BEFORE_ACTION; + } + } +} Propchange: geronimo/trunk/applications/console-standard/src/java/org/apache/geronimo/console/car/ResultsHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/portlet.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/portlet.xml?rev=388671&r1=388670&r2=388671&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/portlet.xml (original) +++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/portlet.xml Fri Mar 24 15:01:45 2006 @@ -1066,5 +1066,29 @@ + + Portlet for CAR Import/Export + ImportExport + CAR Import/Export Portlet + + org.apache.geronimo.console.car.ImportExportPortlet + + -1 + + + text/html + VIEW + HELP + + + en + + + Import/Export Configurations + Import/Export + Import Export CAR Configuration + + + Added: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp (added) +++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp Fri Mar 24 15:01:45 2006 @@ -0,0 +1,32 @@ +<%@ page import="org.apache.geronimo.console.util.PortletManager"%> +<%@ 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"%> + + +

Downloaded ${configId}

+ +

Parent Configurations

+
    + +
  • ${config}
  • +
    +
+ +

JAR Dependencies

+
    + +
  • ${jar}
  • +
    +
+ +
+ + + + + + +
+ +

">Cancel

Propchange: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/download.jsp ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/index.jsp URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/index.jsp?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/index.jsp (added) +++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/index.jsp Fri Mar 24 15:01:45 2006 @@ -0,0 +1,34 @@ +<%@ page import="org.apache.geronimo.console.util.PortletManager"%> +<%@ 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"%> + +

This portlet lets you import or export Geronimo configurations from a Maven repository. + This can be used to install new features into a Geronimo server at runtime.

+ +

Export Configurations

+ +

Choose a configuration in the current Geronimo server to export:

+ +
+ + +
+ +

Import Configurations

+ +

Choose a remote repository to inspect for available Geronimo configurations. The +repository must have a geronimo-configurations.properties file in the root directory +listing the available configurations in the repository (this requirement should be +relaxed in a future update).

+ +
+ + Repository: + +
Propchange: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/index.jsp ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp (added) +++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp Fri Mar 24 15:01:45 2006 @@ -0,0 +1,26 @@ +<%@ page import="org.apache.geronimo.console.util.PortletManager"%> +<%@ 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"%> + +

These are the configurations available in the selected repository. The entries +that are hyperlinks may be installed into the local server. The other entries are +already available in the local server.

+ +

Available Configurations:

+ + +

${category.key}

+ +
Propchange: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/list.jsp ------------------------------------------------------------------------------ svn:eol-style = native Added: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/results.jsp URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/results.jsp?rev=388671&view=auto ============================================================================== --- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/results.jsp (added) +++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/results.jsp Fri Mar 24 15:01:45 2006 @@ -0,0 +1,30 @@ +<%@ page import="org.apache.geronimo.console.util.PortletManager"%> +<%@ 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"%> + +

The configuration ${configId} has been installed. This included:

+ + +

Configurations:

+
    + +
  • ${config.name} (${config.action})
  • +
    +
+
+ + +

Additional JARs:

+
    + +
  • ${dep.name} (${dep.action})
  • +
    +
+
+ +
+ + + +
Propchange: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/view/car/results.jsp ------------------------------------------------------------------------------ svn:eol-style = native Modified: geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewcvs/geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/web.xml?rev=388671&r1=388670&r2=388671&view=diff ============================================================================== --- geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/web.xml (original) +++ geronimo/trunk/applications/console-standard/src/webapp/WEB-INF/web.xml Fri Mar 24 15:01:45 2006 @@ -714,6 +714,20 @@ console-standard.RunSQL + + Automated generated Portlet Wrapper + Pluto Wrapper for CAR Import/Export Portlet + ImportExport + org.apache.pluto.core.PortletServlet + + portlet-class + org.apache.geronimo.console.car.ImportExportPortlet + + + portlet-guid + console-standard.ImportExport + + @@ -726,11 +740,20 @@ true + + CAR Export Servlet + car-export + org.apache.geronimo.console.car.CARExportServlet + dwr-invoker /dwr/* + + car-export + /car-export + @@ -943,6 +966,10 @@ RunSQL /RunSQL/* + + + ImportExport + /ImportExport/*