001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.console.car; 018 019 import java.io.IOException; 020 021 import javax.portlet.ActionRequest; 022 import javax.portlet.ActionResponse; 023 import javax.portlet.PortletException; 024 import javax.portlet.RenderRequest; 025 import javax.portlet.RenderResponse; 026 import javax.portlet.WindowState; 027 028 import org.apache.geronimo.console.MultiPageModel; 029 import org.apache.geronimo.system.plugin.PluginInstaller; 030 import org.apache.geronimo.system.plugin.model.PluginListType; 031 032 /** 033 * Handler for the import export list screen. 034 * 035 * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $ 036 */ 037 public class AssemblyListHandler extends AbstractListHandler { 038 039 public AssemblyListHandler() { 040 super(LIST_SERVER_MODE, "/WEB-INF/view/car/assemblylist.jsp"); 041 } 042 043 public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { 044 String column = (String) request.getAttribute("column"); 045 String relativeServerPath = request.getParameter("relativeServerPath"); 046 String groupId = request.getParameter("groupId"); 047 String artifactId = request.getParameter("artifactId"); 048 String version = request.getParameter("version"); 049 String format = request.getParameter("format"); 050 051 if(!isEmpty(column)) response.setRenderParameter("column", column); 052 response.setRenderParameter("relativeServerPath", isEmpty(relativeServerPath) ? "var/temp/assembly" : relativeServerPath); 053 if(!isEmpty(groupId)) response.setRenderParameter("groupId", groupId); 054 if(!isEmpty(artifactId)) response.setRenderParameter("artifactId", artifactId); 055 response.setRenderParameter("version", isEmpty(version) ? "1.0" : version); 056 if(!isEmpty(format)) response.setRenderParameter("format", format); 057 058 response.setWindowState(WindowState.MAXIMIZED); 059 060 return getMode(); 061 } 062 063 public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException { 064 String column = request.getParameter("column"); 065 String relativeServerPath = request.getParameter("relativeServerPath"); 066 String groupId = request.getParameter("groupId"); 067 String artifactId = request.getParameter("artifactId"); 068 String version = request.getParameter("version"); 069 String format = request.getParameter("format"); 070 if(!loadFromServer(request)) { 071 //todo: loading failed -- do something! 072 } 073 request.setAttribute("column", column); 074 request.setAttribute("relativeServerPath", relativeServerPath); 075 request.setAttribute("groupId", groupId); 076 request.setAttribute("artifactId", artifactId); 077 request.setAttribute("version", version); 078 request.setAttribute("format", format); 079 } 080 081 public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException { 082 return getMode()+BEFORE_ACTION; 083 } 084 085 private boolean loadFromServer(RenderRequest request) throws IOException, PortletException { 086 087 PluginInstaller pluginInstaller = ManagementHelper.getManagementHelper(request).getPluginInstaller(); 088 089 // try to reuse the catalog data if it was already downloaded 090 PluginListType data = getServerPluginList(request, pluginInstaller); 091 092 if(data == null || data.getPlugin() == null) { 093 return false; 094 } 095 096 listPlugins(request, pluginInstaller, data, false); 097 request.getPortletSession(true).setAttribute(SERVER_CONFIG_LIST_SESSION_KEY, data); 098 return true; 099 } 100 101 }