1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.util;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.util.StringMaker;
28  import com.liferay.portal.model.Company;
29  import com.liferay.portal.model.Layout;
30  import com.liferay.portal.model.LayoutSet;
31  import com.liferay.portal.model.Portlet;
32  import com.liferay.portal.model.User;
33  import com.liferay.portal.theme.ThemeDisplay;
34  
35  import java.io.IOException;
36  
37  import java.rmi.RemoteException;
38  
39  import java.util.Date;
40  import java.util.Locale;
41  import java.util.Map;
42  import java.util.TimeZone;
43  
44  import javax.portlet.ActionRequest;
45  import javax.portlet.ActionResponse;
46  import javax.portlet.PortletMode;
47  import javax.portlet.PortletPreferences;
48  import javax.portlet.PortletRequest;
49  import javax.portlet.PortletResponse;
50  import javax.portlet.PreferencesValidator;
51  import javax.portlet.RenderRequest;
52  import javax.portlet.ValidatorException;
53  import javax.portlet.WindowState;
54  
55  import javax.servlet.ServletContext;
56  import javax.servlet.ServletException;
57  import javax.servlet.http.HttpServletRequest;
58  import javax.servlet.http.HttpServletResponse;
59  import javax.servlet.http.HttpSession;
60  
61  /**
62   * <a href="Portal.java.html"><b><i>View Source</i></b></a>
63   *
64   * @author Brian Wing Shun Chan
65   *
66   */
67  public interface Portal {
68  
69      public static final String PATH_IMAGE = "/image";
70  
71      public static final String PATH_MAIN = "/c";
72  
73      public static final String PATH_PORTAL_LAYOUT = "/portal/layout";
74  
75      public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.xml";
76  
77      public static final String PORTLET_XML_FILE_NAME_CUSTOM =
78          "portlet-custom.xml";
79  
80      public static final Date UP_TIME = new Date();
81  
82      public void clearRequestParameters(RenderRequest req);
83  
84      public void copyRequestParameters(ActionRequest req, ActionResponse res);
85  
86      public String getCDNHost();
87  
88      public String getClassName(long classNameId);
89  
90      public long getClassNameId(Class<?> classObj);
91  
92      public long getClassNameId(String value);
93  
94      public String getClassNamePortletId(String className);
95  
96      public String getCommunityLoginURL(ThemeDisplay themeDisplay)
97          throws PortalException, SystemException;
98  
99      public Company getCompany(HttpServletRequest req)
100         throws PortalException, SystemException;
101 
102     public Company getCompany(ActionRequest req)
103         throws PortalException, SystemException;
104 
105     public Company getCompany(RenderRequest req)
106         throws PortalException, SystemException;
107 
108     public long getCompanyId(HttpServletRequest req);
109 
110     public long getCompanyId(ActionRequest req);
111 
112     public long getCompanyId(PortletRequest req);
113 
114     public long getCompanyId(RenderRequest req);
115 
116     public long getCompanyIdByWebId(ServletContext ctx);
117 
118     public long getCompanyIdByWebId(String webId);
119 
120     public String getComputerName();
121 
122     public String getCurrentURL(HttpServletRequest req);
123 
124     public String getCurrentURL(PortletRequest req);
125 
126     public Date getDate(int month, int day, int year, PortalException pe)
127         throws PortalException;
128 
129     public Date getDate(
130             int month, int day, int year, TimeZone timeZone, PortalException pe)
131         throws PortalException;
132 
133     public Date getDate(
134             int month, int day, int year, int hour, int min, PortalException pe)
135         throws PortalException;
136 
137     public Date getDate(
138             int month, int day, int year, int hour, int min, TimeZone timeZone,
139             PortalException pe)
140         throws PortalException;
141 
142     public String getHost(HttpServletRequest req);
143 
144     public String getHost(ActionRequest req);
145 
146     public String getHost(RenderRequest req);
147 
148     public HttpServletRequest getHttpServletRequest(PortletRequest req);
149 
150     public HttpServletResponse getHttpServletResponse(PortletResponse res);
151 
152     public String getLayoutEditPage(Layout layout);
153 
154     public String getLayoutViewPage(Layout layout);
155 
156     public String getLayoutURL(ThemeDisplay themeDisplay)
157         throws PortalException, SystemException;
158 
159     public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay)
160         throws PortalException, SystemException;
161 
162     public String getLayoutURL(
163             Layout layout, ThemeDisplay themeDisplay, boolean doAsUser)
164         throws PortalException, SystemException;
165 
166     public String getLayoutActualURL(Layout layout)
167         throws PortalException, SystemException;
168 
169     public String getLayoutActualURL(Layout layout, String mainPath)
170         throws PortalException, SystemException;
171 
172     public String getLayoutActualURL(
173             long groupId, boolean privateLayout, String mainPath,
174             String friendlyURL)
175         throws PortalException, SystemException;
176 
177     public String getLayoutActualURL(
178             long groupId, boolean privateLayout, String mainPath,
179             String friendlyURL, Map<String, String[]> params)
180         throws PortalException, SystemException;
181 
182     public String getLayoutFriendlyURL(Layout layout, ThemeDisplay themeDisplay)
183         throws PortalException, SystemException;
184 
185     public String getLayoutSetFriendlyURL(
186             LayoutSet layoutSet, ThemeDisplay themeDisplay)
187         throws PortalException, SystemException;
188 
189     public String getLayoutTarget(Layout layout);
190 
191     public String getJsSafePortletId(String portletId) ;
192 
193     public Locale getLocale(HttpServletRequest req);
194 
195     public Locale getLocale(RenderRequest req);
196 
197     public HttpServletRequest getOriginalServletRequest(
198         HttpServletRequest req);
199 
200     public String getPathContext();
201 
202     public String getPathFriendlyURLPrivateGroup();
203 
204     public String getPathFriendlyURLPrivateUser();
205 
206     public String getPathFriendlyURLPublic();
207 
208     public String getPathImage();
209 
210     public String getPathMain();
211 
212     public long getPlidIdFromFriendlyURL(long companyId, String friendlyURL);
213 
214     public String getPortalLibDir();
215 
216     public String getPortalURL(ThemeDisplay themeDisplay);
217 
218     public String getPortalURL(HttpServletRequest req);
219 
220     public String getPortalURL(HttpServletRequest req, boolean secure);
221 
222     public String getPortalURL(PortletRequest req);
223 
224     public String getPortalURL(PortletRequest req, boolean secure);
225 
226     public String getPortalURL(
227         String serverName, int serverPort, boolean secure);
228 
229     public Object[] getPortletFriendlyURLMapper(
230             long groupId, boolean privateLayout, String url)
231         throws PortalException, SystemException;
232 
233     public Object[] getPortletFriendlyURLMapper(
234             long groupId, boolean privateLayout, String url,
235             Map<String, String[]> params)
236         throws PortalException, SystemException;
237 
238     public long getPortletGroupId(long plid);
239 
240     public long getPortletGroupId(Layout layout);
241 
242     public long getPortletGroupId(HttpServletRequest req);
243 
244     public long getPortletGroupId(ActionRequest req);
245 
246     public long getPortletGroupId(RenderRequest req);
247 
248     public String getPortletNamespace(String portletId);
249 
250     public String getPortletTitle(
251         String portletId, long companyId, String languageId);
252 
253     public String getPortletTitle(
254         String portletId, long companyId, Locale locale);
255 
256     public String getPortletTitle(String portletId, User user);
257 
258     public String getPortletTitle(
259         Portlet portlet, ServletContext ctx, Locale locale);
260 
261     public String getPortletXmlFileName()
262         throws PortalException, SystemException;
263 
264     public PortletPreferences getPreferences(HttpServletRequest req);
265 
266     public PreferencesValidator getPreferencesValidator(
267         Portlet portlet);
268 
269     public User getSelectedUser(HttpServletRequest req)
270         throws PortalException, RemoteException, SystemException;
271 
272     public User getSelectedUser(HttpServletRequest req, boolean checkPermission)
273         throws PortalException, RemoteException, SystemException;
274 
275     public User getSelectedUser(ActionRequest req)
276         throws PortalException, RemoteException, SystemException;
277 
278     public User getSelectedUser(ActionRequest req, boolean checkPermission)
279         throws PortalException, RemoteException, SystemException;
280 
281     public User getSelectedUser(RenderRequest req)
282         throws PortalException, RemoteException, SystemException;
283 
284     public User getSelectedUser(RenderRequest req, boolean checkPermission)
285         throws PortalException, RemoteException, SystemException;
286 
287     public String getStrutsAction(HttpServletRequest req);
288 
289     public String[] getSystemCommunityRoles();
290 
291     public String[] getSystemGroups();
292 
293     public String[] getSystemOrganizationRoles();
294 
295     public String[] getSystemRoles();
296 
297     public Date getUptime();
298 
299     public String getURLWithSessionId(String url, String sessionId);
300 
301     public User getUser(HttpServletRequest req)
302         throws PortalException, SystemException;
303 
304     public User getUser(ActionRequest req)
305         throws PortalException, SystemException;
306 
307     public User getUser(RenderRequest req)
308         throws PortalException, SystemException;
309 
310     public long getUserId(HttpServletRequest req);
311 
312     public long getUserId(ActionRequest req);
313 
314     public long getUserId(RenderRequest req);
315 
316     public String getUserName(long userId, String defaultUserName);
317 
318     public String getUserName(
319         long userId, String defaultUserName, String userAttribute);
320 
321     public String getUserName(
322         long userId, String defaultUserName, HttpServletRequest req);
323 
324     public String getUserName(
325         long userId, String defaultUserName, String userAttribute,
326         HttpServletRequest req);
327 
328     public String getUserPassword(HttpSession ses);
329 
330     public String getUserPassword(HttpServletRequest req);
331 
332     public String getUserPassword(ActionRequest req);
333 
334     public String getUserPassword(RenderRequest req);
335 
336     public String getUserValue(long userId, String param, String defaultValue)
337         throws SystemException;
338 
339     public boolean isMethodGet(PortletRequest req);
340 
341     public boolean isMethodPost(PortletRequest req);
342 
343     public boolean isLayoutFriendliable(Layout layout);
344 
345     public boolean isLayoutParentable(Layout layout);
346 
347     public boolean isLayoutParentable(String type);
348 
349     public boolean isLayoutSitemapable(Layout layout);
350 
351     public boolean isReservedParameter(String name);
352 
353     public boolean isSystemGroup(String groupName);
354 
355     public boolean isSystemRole(String roleName);
356 
357     public boolean isUpdateAvailable() throws PortalException, SystemException;
358 
359     public void renderPage(
360             StringMaker sm, ServletContext ctx, HttpServletRequest req,
361             HttpServletResponse res, String path)
362         throws IOException, ServletException;
363 
364     public void renderPortlet(
365             StringMaker sm, ServletContext ctx, HttpServletRequest req,
366             HttpServletResponse res, Portlet portlet, String queryString)
367         throws IOException, ServletException;
368 
369     public void renderPortlet(
370             StringMaker sm, ServletContext ctx, HttpServletRequest req,
371             HttpServletResponse res, Portlet portlet, String queryString,
372             String columnId, Integer columnPos, Integer columnCount)
373         throws IOException, ServletException;
374 
375     public void renderPortlet(
376             StringMaker sm, ServletContext ctx, HttpServletRequest req,
377             HttpServletResponse res, Portlet portlet, String queryString,
378             String columnId, Integer columnPos, Integer columnCount,
379             String path)
380         throws IOException, ServletException;
381 
382     public void sendError(
383             int status, Exception e, HttpServletRequest req,
384             HttpServletResponse res)
385         throws IOException, ServletException;
386 
387     /**
388      * Sets the subtitle for a page. This is just a hint and can be overridden
389      * by subsequent calls. The last call to this method wins.
390      *
391      * @param       subtitle the subtitle for a page
392      * @param       req the HTTP servlet request
393      */
394     public void setPageSubtitle(String subtitle, HttpServletRequest req);
395 
396     /**
397      * Sets the whole title for a page. This is just a hint and can be
398      * overridden by subsequent calls. The last call to this method wins.
399      *
400      * @param       title the whole title for a page
401      * @param       req the HTTP servlet request
402      */
403     public void setPageTitle(String title, HttpServletRequest req);
404 
405     public void storePreferences(PortletPreferences prefs)
406         throws IOException, ValidatorException;
407 
408     public PortletMode updatePortletMode(
409             String portletId, User user, Layout layout, PortletMode portletMode,
410             HttpServletRequest req)
411         throws PortalException, RemoteException, SystemException;
412 
413     public WindowState updateWindowState(
414             String portletId, User user, Layout layout, WindowState windowState,
415             HttpServletRequest req)
416         throws PortalException, RemoteException, SystemException;
417 
418 }