/**
*
* Copyright 2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.geronimo.console.car;
import java.io.IOException;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.console.MultiPageModel;
import org.apache.geronimo.kernel.KernelRegistry;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.repository.Artifact;
/**
* Handler for the import results screen.
*
* @version $Rev: 409817 $ $Date: 2006-05-27 09:56:38 +0200 (Sat, 27 May 2006) $
*/
public class ResultsHandler extends BaseImportExportHandler {
private final static Log log = LogFactory.getLog(ResultsHandler.class);
public ResultsHandler() {
super(RESULTS_MODE, "/WEB-INF/view/car/results.jsp");
}
public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
return getMode();
}
public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
String repo = request.getParameter("repository");
String user = request.getParameter("repo-user");
String pass = request.getParameter("repo-pass");
String configId = request.getParameter("configId");
request.setAttribute("configId", configId);
List deps = (List) request.getPortletSession(true).getAttribute("car.install.results");
request.setAttribute("dependencies", deps);
request.setAttribute("repository", repo);
request.setAttribute("repouser", user);
request.setAttribute("repopass", pass);
}
public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
String configId = request.getParameter("configId");
String repo = request.getParameter("repository");
String user = request.getParameter("repo-user");
String pass = request.getParameter("repo-pass");
response.setRenderParameter("repository", repo);
if(!isEmpty(user)) response.setRenderParameter("repo-user", user);
if(!isEmpty(pass)) response.setRenderParameter("repo-pass", pass);
try {
//todo: hide this in PortletManager/ManagementHelper
ConfigurationManager mgr = ConfigurationUtil.getConfigurationManager(KernelRegistry.getSingleKernel());
Artifact artifact = Artifact.create(configId);
mgr.loadConfiguration(artifact);
mgr.startConfiguration(artifact);
return LIST_MODE;
} catch (Exception e) {
log.error("Unable to start configuration "+configId, e);
response.setRenderParameter("configId", configId);
return getMode()+BEFORE_ACTION;
}
}
}