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: */package org.apache.geronimo.console.car;
017:
018: import java.io.IOException;
019:
020: import javax.portlet.ActionRequest;
021: import javax.portlet.ActionResponse;
022: import javax.portlet.PortletException;
023: import javax.portlet.RenderRequest;
024: import javax.portlet.RenderResponse;
025:
026: import org.apache.geronimo.console.MultiPageModel;
027: import org.apache.geronimo.system.plugin.PluginInstaller;
028: import org.apache.geronimo.system.plugin.model.PluginListType;
029:
030: /**
031: * Handler for the import export list screen.
032: *
033: * @version $Rev: 614044 $ $Date: 2008-01-21 15:17:28 -0800 (Mon, 21 Jan 2008) $
034: */
035: public class AssemblyListHandler extends AbstractListHandler {
036:
037: public AssemblyListHandler() {
038: super (LIST_SERVER_MODE, "/WEB-INF/view/car/assemblylist.jsp");
039: }
040:
041: public String actionBeforeView(ActionRequest request,
042: ActionResponse response, MultiPageModel model)
043: throws PortletException, IOException {
044: String column = (String) request.getAttribute("column");
045: String relativeServerPath = request
046: .getParameter("relativeServerPath");
047: String groupId = request.getParameter("groupId");
048: String artifactId = request.getParameter("artifactId");
049: String version = request.getParameter("version");
050: String format = request.getParameter("format");
051:
052: if (!isEmpty(column))
053: response.setRenderParameter("column", column);
054: response.setRenderParameter("relativeServerPath",
055: isEmpty(relativeServerPath) ? "var/temp/assembly"
056: : relativeServerPath);
057: if (!isEmpty(groupId))
058: response.setRenderParameter("groupId", groupId);
059: if (!isEmpty(artifactId))
060: response.setRenderParameter("artifactId", artifactId);
061: if (!isEmpty(version))
062: response.setRenderParameter("version", version);
063: if (!isEmpty(format))
064: response.setRenderParameter("format", format);
065: return getMode();
066: }
067:
068: public void renderView(RenderRequest request,
069: RenderResponse response, MultiPageModel model)
070: throws PortletException, IOException {
071: String column = request.getParameter("column");
072: String relativeServerPath = request
073: .getParameter("relativeServerPath");
074: String groupId = request.getParameter("groupId");
075: String artifactId = request.getParameter("artifactId");
076: String version = request.getParameter("version");
077: String format = request.getParameter("format");
078: if (!loadFromServer(request)) {
079: //todo: loading failed -- do something!
080: }
081: request.setAttribute("column", column);
082: request.setAttribute("relativeServerPath", relativeServerPath);
083: request.setAttribute("groupId", groupId);
084: request.setAttribute("artifactId", artifactId);
085: request.setAttribute("version", version);
086: request.setAttribute("format", format);
087: }
088:
089: public String actionAfterView(ActionRequest request,
090: ActionResponse response, MultiPageModel model)
091: throws PortletException, IOException {
092: return getMode() + BEFORE_ACTION;
093: }
094:
095: private boolean loadFromServer(RenderRequest request)
096: throws IOException, PortletException {
097:
098: PluginInstaller pluginInstaller = ManagementHelper
099: .getManagementHelper(request).getPluginInstaller();
100:
101: // try to reuse the catalog data if it was already downloaded
102: PluginListType data = getServerPluginList(request,
103: pluginInstaller);
104:
105: if (data == null || data.getPlugin() == null) {
106: return false;
107: }
108:
109: listPlugins(request, pluginInstaller, data, false);
110: request.getPortletSession(true).setAttribute(
111: SERVER_CONFIG_LIST_SESSION_KEY, data);
112: return true;
113: }
114:
115: }
|