1 17 package org.apache.geronimo.console.car; 18 19 import org.apache.geronimo.kernel.Kernel; 20 import org.apache.geronimo.kernel.KernelRegistry; 21 import org.apache.geronimo.kernel.config.ConfigurationManager; 22 import org.apache.geronimo.kernel.config.ConfigurationStore; 23 import org.apache.geronimo.kernel.config.ConfigurationUtil; 24 import org.apache.geronimo.kernel.config.NoSuchConfigException; 25 import org.apache.geronimo.kernel.repository.Artifact; 26 27 import javax.servlet.ServletException ; 28 import javax.servlet.http.HttpServlet ; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 import java.io.IOException ; 32 33 38 public class CARExportServlet extends HttpServlet { 39 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { 40 String configId = request.getParameter("configId"); 41 if(configId == null) { 42 throw new ServletException ("No configId specified for CAR download"); 43 } 44 Artifact artifact = Artifact.create(configId); 45 Kernel kernel = KernelRegistry.getSingleKernel(); 46 ConfigurationManager mgr = ConfigurationUtil.getConfigurationManager(kernel); 47 ConfigurationStore store = mgr.getStoreForConfiguration(artifact); 48 try { 49 response.setContentType("application/zip"); 50 store.exportConfiguration(artifact, response.getOutputStream()); 51 } catch (NoSuchConfigException e) { 52 throw new ServletException ("No such configuration '"+configId+"'"); 53 } 54 } 55 } 56 | Popular Tags |