KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > console > ldapmanager > LDAPManagerPortlet


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17
18 package org.apache.geronimo.console.ldapmanager;
19
20 import java.io.IOException JavaDoc;
21 import java.io.PrintWriter JavaDoc;
22
23 import javax.portlet.ActionRequest;
24 import javax.portlet.ActionResponse;
25 import javax.portlet.PortletConfig;
26 import javax.portlet.PortletContext;
27 import javax.portlet.PortletException;
28 import javax.portlet.PortletRequestDispatcher;
29 import javax.portlet.RenderRequest;
30 import javax.portlet.RenderResponse;
31 import javax.portlet.WindowState;
32
33 import org.apache.geronimo.console.BasePortlet;
34
35 /**
36  * The LDAP manager portlet
37  */

38 public class LDAPManagerPortlet extends BasePortlet {
39     private static final String JavaDoc VIEWLDAPSERVER_ACTION = "viewLDAPServer";
40
41     private static final String JavaDoc VIEWLDAPSERVER_JSP = "/WEB-INF/view/ldapmanager/viewLDAPServer.jsp";
42
43     private static final String JavaDoc HELP_JSP = "/WEB-INF/view/ldapmanager/help.jsp";
44
45     private PortletRequestDispatcher viewLDAPServerView;
46
47     private PortletRequestDispatcher helpView;
48
49     private static LDAPManagerHelper helper = null /* new LDAPManagerHelper() */;
50
51     /**
52      * Process an action request
53      */

54     public void processAction(ActionRequest actionRequest,
55             ActionResponse actionResponse) throws PortletException, IOException JavaDoc {
56     }
57
58     /**
59      * Serve up the view mode
60      */

61     protected void doView(RenderRequest renderRequest,
62             RenderResponse renderResponse) throws IOException JavaDoc, PortletException {
63         if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
64             return;
65         } else if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
66             String JavaDoc action = renderRequest.getParameter("action");
67             if (action == null) {
68                 action = VIEWLDAPSERVER_ACTION;
69             }
70             if (VIEWLDAPSERVER_ACTION.equals(action)) {
71                 viewLDAPServerView.include(renderRequest, renderResponse);
72             } else {
73                 renderResponse.setContentType("text/html");
74                 PrintWriter JavaDoc out = renderResponse.getWriter();
75                 String JavaDoc errorMsg = "Invalid action message: " + action;
76                 out.println(errorMsg);
77             }
78         } else if (WindowState.MAXIMIZED.equals(renderRequest.getWindowState())) {
79             renderResponse.setContentType("text/html");
80             PrintWriter JavaDoc out = renderResponse.getWriter();
81             String JavaDoc errorMsg = "Invalid window state: "
82                     + renderRequest.getWindowState();
83             out.println(errorMsg);
84         }
85     }
86
87     /**
88      * Serve up the help mode
89      */

90     protected void doHelp(RenderRequest renderRequest,
91             RenderResponse renderResponse) throws PortletException, IOException JavaDoc {
92         helpView.include(renderRequest, renderResponse);
93     }
94
95     /**
96      * Portlet is being placed into service
97      */

98     public void init(PortletConfig portletConfig) throws PortletException {
99         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 }
114
Popular Tags