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     */
017    package org.apache.geronimo.console.apache.jk;
018    
019    import java.io.IOException;
020    
021    import org.apache.geronimo.console.MultiPageAbstractHandler;
022    import org.apache.geronimo.console.MultiPagePortlet;
023    import org.apache.geronimo.console.apache.jk.BaseApacheHandler.ApacheModel;
024    
025    import javax.portlet.PortletConfig;
026    import javax.portlet.PortletException;
027    import javax.portlet.PortletRequest;
028    import javax.portlet.RenderRequest;
029    import javax.portlet.RenderResponse;
030    import javax.portlet.WindowState;
031    
032    /**
033     * Portlet that helps you configure Geronimo for Apache 2 with mod_jk
034     *
035     * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
036     */
037    public class ApacheConfigPortlet extends MultiPagePortlet {
038        public void init(PortletConfig config) throws PortletException {
039            super.init(config);
040            addHelper(new IndexHandler(), config);
041            addHelper(new ConfigHandler(), config);
042            addHelper(new AJPHandler(), config);
043            addHelper(new WebAppHandler(), config);
044            addHelper(new ResultsHandler(), config);
045        }
046    
047        public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
048            if(WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
049                return;
050            }
051            String mode = renderRequest.getParameter(MODE_KEY);
052            ApacheModel model = (ApacheModel)getModel(renderRequest);
053            if(mode == null || mode.equals("")) {
054                mode = getDefaultMode();
055            }
056            MultiPageAbstractHandler handler = (MultiPageAbstractHandler)helpers.get(mode);
057            try {
058                if(handler != null) {
059                    handler.renderView(renderRequest, renderResponse, model);
060                }
061            } catch (Throwable e) {
062                
063            }
064            // decode the paths in model object
065            model.setLogFilePath(model.getLogFilePath());
066            model.setWorkersPath(model.getWorkersPath());
067            renderRequest.setAttribute(getModelJSPVariableName(), model);
068            if(handler != null) {
069                handler.getView().include(renderRequest, renderResponse);
070            }
071        }
072    
073        protected String getModelJSPVariableName() {
074            return "model";
075        }
076    
077        protected ApacheModel getModel(PortletRequest request) {
078            return new BaseApacheHandler.ApacheModel(request);
079        }
080    }