geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
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 GMT
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 @@
             </fragment>
         </fragment>
 
+        <fragment name="import" type="page">
+            <navigation>
+                <title>Import/Export</title>
+                <description>ico_list_16x16.gif Import and export configurations for this server</description>
+            </navigation>
+
+            <fragment name="row1" type="row">
+                <fragment name="col1" type="column">
+                    <fragment name="p1" type="portlet">
+                        <property name="portlet" value="5.70"/>
+                    </fragment>
+                </fragment>
+            </fragment>
+        </fragment>
+
     </fragment>
 
     <fragment name="Security" type="page">

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 @@
         <portlet id="69">
             <definition-id>console-standard.Keystores</definition-id>
         </portlet>
+        <portlet id="70">
+            <definition-id>console-standard.ImportExport</definition-id>
+        </portlet>
     </application>
 </portlet-entity-registry>

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("<html><body><p>Error: no LocalConfigStore found in kernel</p></body></html>");
+    }
+}

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-info>
     </portlet>
 
+    <portlet>
+        <description>Portlet for CAR Import/Export</description>
+        <portlet-name>ImportExport</portlet-name>
+        <display-name>CAR Import/Export Portlet</display-name>
+
+        <portlet-class>org.apache.geronimo.console.car.ImportExportPortlet</portlet-class>
+
+        <expiration-cache>-1</expiration-cache>
+
+        <supports>
+            <mime-type>text/html</mime-type>
+            <portlet-mode>VIEW</portlet-mode>
+            <portlet-mode>HELP</portlet-mode>
+        </supports>
+
+        <supported-locale>en</supported-locale>
+
+        <portlet-info>
+            <title>Import/Export Configurations</title>
+            <short-title>Import/Export</short-title>
+            <keywords>Import Export CAR Configuration</keywords>
+        </portlet-info>
+    </portlet>
+
     <!-- End of console portlets -->
 </portlet-app>

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"%>
+<portlet:defineObjects/>
+
+<p>Downloaded ${configId}</p>
+
+<p>Parent Configurations</p>
+<ul>
+<c:forEach var="config" items="${parents}">
+    <li>${config}</li>
+</c:forEach>
+</ul>
+
+<p>JAR Dependencies</p>
+<ul>
+<c:forEach var="jar" items="${dependencies}">
+    <li>${jar}</li>
+</c:forEach>
+</ul>
+
+<form name="<portlet:namespace/>KeystoreForm" 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" />
+    <input type="hidden" name="repository" value="${repository}" />
+    <input type="hidden" name="proceed" value="true" />
+    <input type="submit" value="Install Configuration" />
+</form>
+
+<p><a href="<portlet:actionURL portletMode="view"><portlet:param name="mode" value="index-before" /></portlet:actionURL>">Cancel</a></p>

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"%>
+<portlet:defineObjects/>
+<p>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.</p>
+
+<h2>Export Configurations</h2>
+
+<p>Choose a configuration in the current Geronimo server to export:</p>
+
+<form action="<%=request.getContextPath()%>/car-export">
+    <select name="configId">
+        <option />
+      <c:forEach var="config" items="${configurations}">
+        <option>${config.configID}</option>
+      </c:forEach>
+    </select>
+    <input type="submit" value="Export Configuration" />
+</form>
+
+<h2>Import Configurations</h2>
+
+<p>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).</p>
+
+<form name="<portlet:namespace/>KeystoreForm" action="<portlet:actionURL/>">
+    <input type="hidden" name="mode" value="index-after" />
+    Repository: <input type="text" name="repository" value="http://localhost/maven/" size="20" maxlength="200" />
+    <input type="submit" value="Search for Configurations" />
+</form>

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"%>
+<portlet:defineObjects/>
+<p>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.</p>
+
+<p><b>Available Configurations:</b></p>
+
+<c:forEach var="category" items="${categories}">
+  <p>${category.key}</p>
+  <ul>
+    <c:forEach var="entry" items="${category.value}">
+      <c:choose>
+        <c:when test="${entry.installed}">
+          <li>${entry.name}</li>
+        </c:when>
+        <c:otherwise>
+          <li><a href="<portlet:actionURL><portlet:param name="configId" value="${entry.configId}"/><portlet:param name="repository" value="${repository}"/><portlet:param name="mode" value="download-before"/></portlet:actionURL>">${entry.name} (${entry.version})</a></li>
+        </c:otherwise>
+      </c:choose>
+    </c:forEach>
+  </ul>
+</c:forEach>

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"%>
+<portlet:defineObjects/>
+<p>The configuration ${configId} has been installed.  This included:</p>
+
+<c:if test="${! empty configurations}">
+  <p><b>Configurations:</b></p>
+  <ul>
+    <c:forEach var="config" items="${configurations}">
+      <li>${config.name} (${config.action})</li>
+    </c:forEach>
+  </ul>
+</c:if>
+
+<c:if test="${! empty dependencies}">
+  <p><b>Additional JARs:</b></p>
+  <ul>
+    <c:forEach var="dep" items="${dependencies}">
+      <li>${dep.name} (${dep.action})</li>
+    </c:forEach>
+  </ul>
+</c:if>
+
+<form name="<portlet:namespace/>KeystoreForm" action="<portlet:actionURL/>">
+    <input type="hidden" name="mode" value="results-after" />
+    <input type="hidden" name="configId" value="${configId}" />
+    <input type="submit" value="Start ${configId}" />
+</form>

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 @@
             <param-value>console-standard.RunSQL</param-value>
         </init-param>
     </servlet>
+    <servlet>
+        <description>Automated generated Portlet Wrapper</description>
+        <display-name>Pluto Wrapper for CAR Import/Export Portlet</display-name>
+        <servlet-name>ImportExport</servlet-name>
+        <servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
+        <init-param>
+            <param-name>portlet-class</param-name>
+            <param-value>org.apache.geronimo.console.car.ImportExportPortlet</param-value>
+        </init-param>
+        <init-param>
+            <param-name>portlet-guid</param-name>
+            <param-value>console-standard.ImportExport</param-value>
+        </init-param>
+    </servlet>
 
 
 
@@ -726,11 +740,20 @@
      <param-value>true</param-value>
   </init-param>
 </servlet>
+<servlet>
+  <display-name>CAR Export Servlet</display-name>
+  <servlet-name>car-export</servlet-name>
+  <servlet-class>org.apache.geronimo.console.car.CARExportServlet</servlet-class>
+</servlet>
 
 <servlet-mapping>
   <servlet-name>dwr-invoker</servlet-name>
   <url-pattern>/dwr/*</url-pattern>
 </servlet-mapping>
+<servlet-mapping>
+  <servlet-name>car-export</servlet-name>
+  <url-pattern>/car-export</url-pattern>
+</servlet-mapping>
 
 
 
@@ -943,6 +966,10 @@
     <servlet-mapping>
         <servlet-name>RunSQL</servlet-name>
         <url-pattern>/RunSQL/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>ImportExport</servlet-name>
+        <url-pattern>/ImportExport/*</url-pattern>
     </servlet-mapping>
 
 <!-- org.apache.geronimo.console.core.securitymanager.SecurityRealmsPortlet

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java?rev=388671&r1=388670&r2=388671&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java Fri Mar 24 15:01:45 2006
@@ -36,6 +36,7 @@
 import java.util.Properties;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
@@ -431,6 +432,49 @@
         }
     }
 
+    public void exportConfiguration(String configId, OutputStream output) throws IOException, NoSuchConfigException {
+        String dirName = index.getProperty(configId);
+        if(dirName == null) {
+            throw new NoSuchConfigException("No such config: " + configId);
+        }
+        File dir = new File(rootDir, dirName);
+        if(!dir.exists() || !dir.canRead()) {
+            throw new IOException("Cannot read config store directory for "+configId+" ("+dir.getAbsolutePath()+")");
+        }
+        ZipOutputStream out = new ZipOutputStream(output);
+        byte[] buf = new byte[10240];
+        writeToZip(dir, out, "", buf);
+        out.closeEntry();
+        out.finish();
+        out.flush();
+    }
+
+    private void writeToZip(File dir, ZipOutputStream out, String prefix, byte[] buf) throws IOException {
+        File[] all = dir.listFiles();
+        for (int i = 0; i < all.length; i++) {
+            File file = all[i];
+            if(file.isDirectory()) {
+                writeToZip(file, out, prefix+file.getName()+"/", buf);
+            } else {
+                ZipEntry entry = new ZipEntry(prefix+file.getName());
+                out.putNextEntry(entry);
+                writeToZipStream(file, out, buf);
+            }
+        }
+    }
+
+    private void writeToZipStream(File file, OutputStream out, byte[] buf) throws IOException {
+        FileInputStream in = new FileInputStream(file);
+        int count;
+        try {
+            while((count = in.read(buf, 0, buf.length)) > -1) {
+                out.write(buf, 0, count);
+            }
+        } finally {
+            in.close();
+        }
+    }
+
     private static void delete(File root) throws IOException {
         File[] files = root.listFiles();
         if ( null == files ) {
@@ -457,6 +501,7 @@
         infoFactory.addAttribute("objectName", String.class, false);
         infoFactory.addAttribute("root", URI.class, true);
         infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
+        infoFactory.addOperation("exportConfiguration", new Class[]{String.class, OutputStream.class});
         infoFactory.addInterface(ConfigurationStore.class);
 
         infoFactory.setConstructor(new String[]{"kernel", "objectName", "root", "ServerInfo"});



Mime
View raw message