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.internaldb;
017:
018: import java.io.IOException;
019: import java.util.HashMap;
020: import java.util.Map;
021:
022: import javax.portlet.ActionRequest;
023: import javax.portlet.ActionResponse;
024: import javax.portlet.PortletConfig;
025: import javax.portlet.PortletException;
026: import javax.portlet.PortletRequestDispatcher;
027: import javax.portlet.RenderRequest;
028: import javax.portlet.RenderResponse;
029: import javax.portlet.WindowState;
030:
031: import org.apache.geronimo.console.BasePortlet;
032:
033: public class InternalDBPortlet extends BasePortlet {
034:
035: private static final String NORMALVIEW_JSP = "/WEB-INF/view/internaldb/internalDBNormal.jsp";
036:
037: private static final String MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/internalDBMaximized.jsp";
038:
039: private static final String HELPVIEW_JSP = "/WEB-INF/view/internaldb/internalDBHelp.jsp";
040:
041: private static InternalDBHelper helper = new InternalDBHelper();
042:
043: private static Map javaSysInfo = new HashMap();
044:
045: private PortletRequestDispatcher normalView;
046:
047: private PortletRequestDispatcher maximizedView;
048:
049: private PortletRequestDispatcher helpView;
050:
051: public void processAction(ActionRequest actionRequest,
052: ActionResponse actionResponse) throws PortletException,
053: IOException {
054: // Getting parameters here because it fails on doView()
055: String rdbms = actionRequest.getParameter("rdbms");
056: if (rdbms != null) {
057: actionResponse.setRenderParameter("rdbms", rdbms);
058: }
059: }
060:
061: protected void doView(RenderRequest renderRequest,
062: RenderResponse renderResponse) throws IOException,
063: PortletException {
064: if (WindowState.MINIMIZED
065: .equals(renderRequest.getWindowState())) {
066: return;
067: }
068:
069: String rdbmsParam = renderRequest.getParameter("rdbms");
070: int rdbms = 1;
071: if ((rdbmsParam != null) && (rdbmsParam.length() > 0)) {
072: rdbms = Integer.parseInt(rdbmsParam);
073: }
074: Map internalDB = helper.getDBInfo();
075: renderRequest.setAttribute("internalDB", internalDB);
076:
077: if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
078: normalView.include(renderRequest, renderResponse);
079: } else {
080: maximizedView.include(renderRequest, renderResponse);
081: }
082: }
083:
084: protected void doHelp(RenderRequest renderRequest,
085: RenderResponse renderResponse) throws PortletException,
086: IOException {
087: helpView.include(renderRequest, renderResponse);
088: }
089:
090: public void init(PortletConfig portletConfig)
091: throws PortletException {
092: super .init(portletConfig);
093: normalView = portletConfig.getPortletContext()
094: .getRequestDispatcher(NORMALVIEW_JSP);
095: maximizedView = portletConfig.getPortletContext()
096: .getRequestDispatcher(MAXIMIZEDVIEW_JSP);
097: helpView = portletConfig.getPortletContext()
098: .getRequestDispatcher(HELPVIEW_JSP);
099: }
100:
101: public void destroy() {
102: normalView = null;
103: maximizedView = null;
104: helpView = null;
105: super.destroy();
106: }
107:
108: }
|