01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.console.car;
17:
18: import java.io.IOException;
19: import java.net.URL;
20: import java.util.ArrayList;
21: import java.util.List;
22:
23: import javax.portlet.ActionRequest;
24: import javax.portlet.ActionResponse;
25: import javax.portlet.PortletException;
26: import javax.portlet.RenderRequest;
27: import javax.portlet.RenderResponse;
28:
29: import org.apache.geronimo.console.MultiPageModel;
30: import org.apache.geronimo.console.util.ConfigurationData;
31: import org.apache.geronimo.console.util.PortletManager;
32: import org.apache.geronimo.system.plugin.PluginRepositoryList;
33:
34: /**
35: * Handler for the import export main screen.
36: *
37: * @version $Rev: 609072 $ $Date: 2008-01-04 16:47:14 -0800 (Fri, 04 Jan 2008) $
38: */
39: public class IndexHandler extends BaseImportExportHandler {
40: public IndexHandler() {
41: super (INDEX_MODE, "/WEB-INF/view/car/index.jsp");
42: }
43:
44: public String actionBeforeView(ActionRequest request,
45: ActionResponse response, MultiPageModel model)
46: throws PortletException, IOException {
47: String repo = request.getParameter("repository");
48: if (repo != null)
49: response.setRenderParameter("repository", repo);
50: return getMode();
51: }
52:
53: public void renderView(RenderRequest request,
54: RenderResponse response, MultiPageModel model)
55: throws PortletException, IOException {
56: List<PluginRepositoryList> lists = ManagementHelper
57: .getManagementHelper(request)
58: .getPluginRepositoryLists();
59:
60: // clear out the catalog if it was previously loaded
61: request.getPortletSession(true).removeAttribute(
62: CONFIG_LIST_SESSION_KEY);
63:
64: List<URL> list = new ArrayList<URL>();
65: for (PluginRepositoryList repo : lists) {
66: list.addAll(repo.getRepositories());
67: }
68: ConfigurationData[] configs = PortletManager.getConfigurations(
69: request, null, false);
70: request.setAttribute("configurations", configs);
71: request.setAttribute("repositories", list);
72: String repository = request.getParameter("repository");
73: request.setAttribute("repository", repository);
74: }
75:
76: public String actionAfterView(ActionRequest request,
77: ActionResponse response, MultiPageModel model)
78: throws PortletException, IOException {
79: request.setAttribute("column", request.getParameter("column"));
80: request.setAttribute("repository", request
81: .getParameter("repository"));
82: request.setAttribute("repo-user", request
83: .getParameter("username"));
84: request.setAttribute("repo-pass", request
85: .getParameter("password"));
86: return LIST_MODE + BEFORE_ACTION;
87: }
88: }
|