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
018 package org.apache.geronimo.console.ldapmanager;
019
020 import java.io.IOException;
021 import java.io.PrintWriter;
022
023 import javax.portlet.ActionRequest;
024 import javax.portlet.ActionResponse;
025 import javax.portlet.PortletConfig;
026 import javax.portlet.PortletContext;
027 import javax.portlet.PortletException;
028 import javax.portlet.PortletRequestDispatcher;
029 import javax.portlet.RenderRequest;
030 import javax.portlet.RenderResponse;
031 import javax.portlet.WindowState;
032
033 import org.apache.geronimo.console.BasePortlet;
034
035 /**
036 * The LDAP manager portlet
037 */
038 public class LDAPManagerPortlet extends BasePortlet {
039 private static final String VIEWLDAPSERVER_ACTION = "viewLDAPServer";
040
041 private static final String VIEWLDAPSERVER_JSP = "/WEB-INF/view/ldapmanager/viewLDAPServer.jsp";
042
043 private static final String HELP_JSP = "/WEB-INF/view/ldapmanager/help.jsp";
044
045 private PortletRequestDispatcher viewLDAPServerView;
046
047 private PortletRequestDispatcher helpView;
048
049 private static LDAPManagerHelper helper = null /* new LDAPManagerHelper() */;
050
051 /**
052 * Process an action request
053 */
054 public void processAction(ActionRequest actionRequest,
055 ActionResponse actionResponse) throws PortletException, IOException {
056 }
057
058 /**
059 * Serve up the view mode
060 */
061 protected void doView(RenderRequest renderRequest,
062 RenderResponse renderResponse) throws IOException, PortletException {
063 if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
064 return;
065 } else if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
066 String action = renderRequest.getParameter("action");
067 if (action == null) {
068 action = VIEWLDAPSERVER_ACTION;
069 }
070 if (VIEWLDAPSERVER_ACTION.equals(action)) {
071 viewLDAPServerView.include(renderRequest, renderResponse);
072 } else {
073 renderResponse.setContentType("text/html");
074 PrintWriter out = renderResponse.getWriter();
075 String errorMsg = "Invalid action message: " + action;
076 out.println(errorMsg);
077 }
078 } else if (WindowState.MAXIMIZED.equals(renderRequest.getWindowState())) {
079 renderResponse.setContentType("text/html");
080 PrintWriter out = renderResponse.getWriter();
081 String errorMsg = "Invalid window state: "
082 + renderRequest.getWindowState();
083 out.println(errorMsg);
084 }
085 }
086
087 /**
088 * Serve up the help mode
089 */
090 protected void doHelp(RenderRequest renderRequest,
091 RenderResponse renderResponse) throws PortletException, IOException {
092 helpView.include(renderRequest, renderResponse);
093 }
094
095 /**
096 * Portlet is being placed into service
097 */
098 public void init(PortletConfig portletConfig) throws PortletException {
099 super.init(portletConfig);
100 PortletContext pc = portletConfig.getPortletContext();
101 viewLDAPServerView = pc.getRequestDispatcher(VIEWLDAPSERVER_JSP);
102 helpView = pc.getRequestDispatcher(HELP_JSP);
103 }
104
105 /**
106 * Portlet is being taken out of service
107 */
108 public void destroy() {
109 viewLDAPServerView = null;
110 helpView = null;
111 super.destroy();
112 }
113 }