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.util.List;
20: import javax.portlet.ActionRequest;
21: import javax.portlet.ActionResponse;
22: import javax.portlet.PortletException;
23: import javax.portlet.RenderRequest;
24: import javax.portlet.RenderResponse;
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27: import org.apache.geronimo.console.MultiPageModel;
28: import org.apache.geronimo.kernel.KernelRegistry;
29: import org.apache.geronimo.kernel.config.ConfigurationManager;
30: import org.apache.geronimo.kernel.config.ConfigurationUtil;
31: import org.apache.geronimo.kernel.repository.Artifact;
32:
33: /**
34: * Handler for the import results screen.
35: *
36: * @version $Rev: 618530 $ $Date: 2008-02-04 20:04:56 -0800 (Mon, 04 Feb 2008) $
37: */
38: public class ResultsHandler extends BaseImportExportHandler {
39: private final static Log log = LogFactory
40: .getLog(ResultsHandler.class);
41:
42: public ResultsHandler() {
43: super (RESULTS_MODE, "/WEB-INF/view/car/results.jsp");
44: }
45:
46: public String actionBeforeView(ActionRequest request,
47: ActionResponse response, MultiPageModel model)
48: throws PortletException, IOException {
49: return getMode();
50: }
51:
52: public void renderView(RenderRequest request,
53: RenderResponse response, MultiPageModel model)
54: throws PortletException, IOException {
55: String repo = request.getParameter("repository");
56: String user = request.getParameter("repo-user");
57: String pass = request.getParameter("repo-pass");
58: String[] configId = request.getParameterValues("configId");
59: request.setAttribute("configId", configId);
60: List deps = (List) request.getPortletSession(true)
61: .getAttribute("car.install.results");
62: request.setAttribute("dependencies", deps);
63: request.setAttribute("repository", repo);
64: request.setAttribute("repouser", user);
65: request.setAttribute("repopass", pass);
66: }
67:
68: public String actionAfterView(ActionRequest request,
69: ActionResponse response, MultiPageModel model)
70: throws PortletException, IOException {
71: String[] configId = request.getParameterValues("configId");
72: String repo = request.getParameter("repository");
73: String user = request.getParameter("repo-user");
74: String pass = request.getParameter("repo-pass");
75: response.setRenderParameter("repository", repo);
76: if (!isEmpty(user))
77: response.setRenderParameter("repo-user", user);
78: if (!isEmpty(pass))
79: response.setRenderParameter("repo-pass", pass);
80: try {
81: //todo: hide this in PortletManager/ManagementHelper
82: for (int i = 0; i < configId.length; i++) {
83: ConfigurationManager mgr = ConfigurationUtil
84: .getConfigurationManager(KernelRegistry
85: .getSingleKernel());
86: Artifact artifact = Artifact.create(configId[i]);
87: mgr.loadConfiguration(artifact);
88: mgr.startConfiguration(artifact);
89: }
90: return INDEX_MODE;
91: //return LIST_MODE;
92: } catch (Exception e) {
93: log.error("Unable to start configuration " + configId, e);
94: response.setRenderParameter("configId", configId);
95: return getMode() + BEFORE_ACTION;
96: }
97: }
98: }
|