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.configcreator;
17:
18: import java.io.File;
19: import java.io.FileWriter;
20: import java.io.IOException;
21: import java.net.URI;
22: import java.net.URISyntaxException;
23:
24: import javax.portlet.ActionRequest;
25: import javax.portlet.ActionResponse;
26: import javax.portlet.PortletException;
27: import javax.portlet.RenderRequest;
28: import javax.portlet.RenderResponse;
29:
30: import org.apache.commons.logging.Log;
31: import org.apache.commons.logging.LogFactory;
32: import org.apache.geronimo.console.MultiPageModel;
33:
34: /**
35: * A handler for ...
36: *
37: * @version $Rev: 565397 $ $Date: 2007-08-13 09:21:44 -0700 (Mon, 13 Aug 2007) $
38: */
39: public class DeployStatusHandler extends AbstractHandler {
40: private static final Log log = LogFactory
41: .getLog(DisplayPlanHandler.class);
42:
43: public DeployStatusHandler() {
44: super (DEPLOY_STATUS_MODE,
45: "/WEB-INF/view/configcreator/deployStatus.jsp");
46: }
47:
48: public String actionBeforeView(ActionRequest request,
49: ActionResponse response, MultiPageModel model)
50: throws PortletException, IOException {
51: return getMode();
52: }
53:
54: public void renderView(RenderRequest request,
55: RenderResponse response, MultiPageModel model)
56: throws PortletException, IOException {
57: WARConfigData data = getSessionData(request);
58: try {
59: File moduleFile = new File(
60: new URI(data.getUploadedWarUri()));
61:
62: File planFile = File.createTempFile("console-deployment",
63: ".xml");
64: planFile.deleteOnExit();
65: FileWriter out = new FileWriter(planFile);
66: out.write(data.getDeploymentPlan());
67: out.close();
68:
69: String[] status = JSR88_Util.deploy(request, moduleFile,
70: planFile);
71: request.setAttribute(DEPLOY_ABBR_STATUS_PARAMETER,
72: status[0]);
73: request.setAttribute(DEPLOY_FULL_STATUS_PARAMETER,
74: status[1]);
75: } catch (URISyntaxException e) {
76: log.error(e.getMessage(), e);
77: }
78: request.setAttribute(DATA_PARAMETER, data);
79: }
80:
81: public String actionAfterView(ActionRequest request,
82: ActionResponse response, MultiPageModel model)
83: throws PortletException, IOException {
84: return "";
85: }
86: }
|