KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > portal > information > DynamicInformationProviderIG


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23 package org.infoglue.deliver.portal.information;
24
25 import java.util.HashSet JavaDoc;
26 import java.util.Iterator JavaDoc;
27
28 import javax.portlet.PortletMode;
29 import javax.portlet.WindowState;
30 import javax.servlet.ServletConfig JavaDoc;
31 import javax.servlet.http.HttpServletRequest JavaDoc;
32
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35 import org.apache.pluto.om.window.PortletWindow;
36 import org.apache.pluto.portalImpl.services.config.Config;
37 import org.apache.pluto.services.information.DynamicInformationProvider;
38 import org.apache.pluto.services.information.PortletActionProvider;
39 import org.apache.pluto.services.information.PortletURLProvider;
40 import org.apache.pluto.services.information.ResourceURLProvider;
41 import org.infoglue.deliver.portal.PortalControlURL;
42
43 /**
44  *
45  * @author jand
46  *
47  */

48 public class DynamicInformationProviderIG implements DynamicInformationProvider {
49     private static final Log log = LogFactory.getLog(DynamicInformationProviderIG.class);
50
51     private final static int NumberOfKnownMimetypes = 15;
52
53     //private HttpServletRequest request;
54
private ServletConfig JavaDoc config;
55     private PortalControlURL url;
56
57     public DynamicInformationProviderIG(HttpServletRequest JavaDoc request, ServletConfig JavaDoc config) {
58         //this.request = request;
59
this.config = config;
60         this.url = new PortalControlURL(request);
61     }
62
63     // DynamicInformationProvider implementation.
64

65     public PortletURLProvider getPortletURLProvider(PortletWindow portletWindow) {
66         log.debug("getPortletURLProvider()");
67         return new PortletURLProviderIG(this, portletWindow);
68     }
69
70     public ResourceURLProvider getResourceURLProvider(PortletWindow portletWindow) {
71         log.debug("getResourceURLProvider()");
72         return new ResourceURLProviderIG(this, portletWindow);
73     }
74
75     public PortletActionProvider getPortletActionProvider(PortletWindow portletWindow) {
76         log.debug("getPortletActionProvider()");
77         return new PortletActionProviderIG(this, portletWindow);
78     }
79
80     public PortletMode getPortletMode(PortletWindow portletWindow) {
81         log.debug("getPortletMode()");
82         return url.getPortletMode(portletWindow);
83     }
84
85     public PortletMode getPreviousPortletMode(PortletWindow portletWindow) {
86         log.debug("getPreviousPortletMode()");
87         return url.getPreviousPortletMode(portletWindow);
88     }
89
90     public WindowState getWindowState(PortletWindow portletWindow) {
91         log.debug("getWindowState()");
92         return url.getWindowState(portletWindow);
93     }
94
95     public WindowState getPreviousWindowState(PortletWindow portletWindow) {
96         log.debug("getPreviousWindowState()");
97         return url.getPreviousWindowState(portletWindow);
98     }
99
100     public String JavaDoc getResponseContentType() {
101         log.debug("getResponseContentType()");
102         return "text/html";
103     }
104
105     public Iterator JavaDoc getResponseContentTypes() {
106         log.debug("getResponseContentTypes()");
107         HashSet JavaDoc responseMimeTypes = new HashSet JavaDoc(NumberOfKnownMimetypes);
108         responseMimeTypes.add("text/html");
109
110         return responseMimeTypes.iterator();
111     }
112
113     public boolean isPortletModeAllowed(PortletMode mode) {
114         log.debug("isPortletModeAllowed()");
115         //checks whether PortletMode is supported as example
116
String JavaDoc[] supportedModes = Config.getParameters().getStrings("supported.portletmode");
117         for (int i = 0; i < supportedModes.length; i++) {
118             if (supportedModes[i].equalsIgnoreCase(mode.toString())) {
119                 return true;
120             }
121         }
122         return false;
123     }
124
125     public boolean isWindowStateAllowed(WindowState state) {
126         log.debug("isWindowStateAllowed()");
127         //checks whether WindowState is supported as example
128
String JavaDoc[] supportedStates = Config.getParameters().getStrings("supported.windowstate");
129         for (int i = 0; i < supportedStates.length; i++) {
130             if (supportedStates[i].equalsIgnoreCase(state.toString())) {
131                 return true;
132             }
133         }
134         return false;
135     }
136
137     // Others
138

139     /**
140      * Return a new portal control URL
141      */

142     public PortalControlURL getPortalURL() {
143         return new PortalControlURL(url);
144     }
145 }
146
Popular Tags