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