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.upload.UploadPortletRequest;
28  import com.liferay.portal.kernel.upload.UploadServletRequest;
29  import com.liferay.portal.model.Company;
30  import com.liferay.portal.model.Layout;
31  import com.liferay.portal.model.LayoutSet;
32  import com.liferay.portal.model.Portlet;
33  import com.liferay.portal.model.User;
34  import com.liferay.portal.theme.ThemeDisplay;
35  
36  import java.io.IOException;
37  
38  import java.rmi.RemoteException;
39  
40  import java.util.Date;
41  import java.util.Locale;
42  import java.util.Map;
43  import java.util.Properties;
44  import java.util.TimeZone;
45  
46  import javax.portlet.ActionRequest;
47  import javax.portlet.ActionResponse;
48  import javax.portlet.PortletMode;
49  import javax.portlet.PortletPreferences;
50  import javax.portlet.PortletRequest;
51  import javax.portlet.PortletResponse;
52  import javax.portlet.PreferencesValidator;
53  import javax.portlet.RenderRequest;
54  import javax.portlet.ValidatorException;
55  import javax.portlet.WindowState;
56  
57  import javax.servlet.ServletContext;
58  import javax.servlet.ServletException;
59  import javax.servlet.http.HttpServletRequest;
60  import javax.servlet.http.HttpServletResponse;
61  import javax.servlet.http.HttpSession;
62  
63  /**
64   * <a href="Portal.java.html"><b><i>View Source</i></b></a>
65   *
66   * @author Brian Wing Shun Chan
67   *
68   */
69  public interface Portal {
70  
71      public static final String PATH_IMAGE = "/image";
72  
73      public static final String PATH_MAIN = "/c";
74  
75      public static final String PATH_PORTAL_LAYOUT = "/portal/layout";
76  
77      public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.xml";
78  
79      public static final String PORTLET_XML_FILE_NAME_CUSTOM =
80          "portlet-custom.xml";
81  
82      public static final Date UP_TIME = new Date();
83  
84      public void clearRequestParameters(RenderRequest renderRequest);
85  
86      public void copyRequestParameters(
87          ActionRequest actionRequest, ActionResponse actionResponse);
88  
89      public String getCDNHost();
90  
91      public String getClassName(long classNameId);
92  
93      public long getClassNameId(Class<?> classObj);
94  
95      public long getClassNameId(String value);
96  
97      public String getClassNamePortletId(String className);
98  
99      public String getCommunityLoginURL(ThemeDisplay themeDisplay)
100         throws PortalException, SystemException;
101 
102     public Company getCompany(HttpServletRequest request)
103         throws PortalException, SystemException;
104 
105     public Company getCompany(ActionRequest actionRequest)
106         throws PortalException, SystemException;
107 
108     public Company getCompany(RenderRequest renderRequest)
109         throws PortalException, SystemException;
110 
111     public long getCompanyId(HttpServletRequest requestuest);
112 
113     public long getCompanyId(ActionRequest actionRequest);
114 
115     public long getCompanyId(PortletRequest portletRequest);
116 
117     public long getCompanyId(RenderRequest renderRequest);
118 
119     public long getCompanyIdByWebId(ServletContext servletContext);
120 
121     public long getCompanyIdByWebId(String webId);
122 
123     public long[] getCompanyIds();
124 
125     public String getComputerAddress();
126 
127     public String getComputerName();
128 
129     public String getCurrentURL(HttpServletRequest request);
130 
131     public String getCurrentURL(PortletRequest portletRequest);
132 
133     public String getCustomSQLFunctionIsNotNull();
134 
135     public String getCustomSQLFunctionIsNull();
136 
137     public Date getDate(int month, int day, int year, PortalException pe)
138         throws PortalException;
139 
140     public Date getDate(
141             int month, int day, int year, TimeZone timeZone, PortalException pe)
142         throws PortalException;
143 
144     public Date getDate(
145             int month, int day, int year, int hour, int min, PortalException pe)
146         throws PortalException;
147 
148     public Date getDate(
149             int month, int day, int year, int hour, int min, TimeZone timeZone,
150             PortalException pe)
151         throws PortalException;
152 
153     public String getHost(HttpServletRequest request);
154 
155     public String getHost(ActionRequest actionRequest);
156 
157     public String getHost(RenderRequest renderRequest);
158 
159     public HttpServletRequest getHttpServletRequest(
160         PortletRequest portletRequest);
161 
162     public HttpServletResponse getHttpServletResponse(
163         PortletResponse portletResponse);
164 
165     public String getLayoutEditPage(Layout layout);
166 
167     public String getLayoutViewPage(Layout layout);
168 
169     public String getLayoutURL(ThemeDisplay themeDisplay);
170 
171     public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay);
172 
173     public String getLayoutURL(
174         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser);
175 
176     public String getLayoutActualURL(Layout layout);
177 
178     public String getLayoutActualURL(Layout layout, String mainPath);
179 
180     public String getLayoutActualURL(
181             long groupId, boolean privateLayout, String mainPath,
182             String friendlyURL)
183         throws PortalException, SystemException;
184 
185     public String getLayoutActualURL(
186             long groupId, boolean privateLayout, String mainPath,
187             String friendlyURL, Map<String, String[]> params)
188         throws PortalException, SystemException;
189 
190     public String getLayoutFriendlyURL(
191         Layout layout, ThemeDisplay themeDisplay);
192 
193     public String getLayoutSetFriendlyURL(
194             LayoutSet layoutSet, ThemeDisplay themeDisplay)
195         throws PortalException, SystemException;
196 
197     public String getLayoutTarget(Layout layout);
198 
199     public String getJsSafePortletId(String portletId) ;
200 
201     public Locale getLocale(HttpServletRequest request);
202 
203     public Locale getLocale(RenderRequest renderRequest);
204 
205     public HttpServletRequest getOriginalServletRequest(
206         HttpServletRequest request);
207 
208     public String getPathContext();
209 
210     public String getPathFriendlyURLPrivateGroup();
211 
212     public String getPathFriendlyURLPrivateUser();
213 
214     public String getPathFriendlyURLPublic();
215 
216     public String getPathImage();
217 
218     public String getPathMain();
219 
220     public long getPlidFromFriendlyURL(long companyId, String friendlyURL);
221 
222     public long getPlidFromPortletId(
223         long groupId, boolean privateLayout, String portletId);
224 
225     public String getPortalLibDir();
226 
227     public int getPortalPort();
228 
229     public Properties getPortalProperties();
230 
231     public String getPortalURL(ThemeDisplay themeDisplay);
232 
233     public String getPortalURL(HttpServletRequest request);
234 
235     public String getPortalURL(HttpServletRequest request, boolean secure);
236 
237     public String getPortalURL(PortletRequest portletRequest);
238 
239     public String getPortalURL(PortletRequest portletRequest, boolean secure);
240 
241     public String getPortalURL(
242         String serverName, int serverPort, boolean secure);
243 
244     public Object[] getPortletFriendlyURLMapper(
245             long groupId, boolean privateLayout, String url)
246         throws PortalException, SystemException;
247 
248     public Object[] getPortletFriendlyURLMapper(
249             long groupId, boolean privateLayout, String url,
250             Map<String, String[]> params)
251         throws PortalException, SystemException;
252 
253     public long getPortletGroupId(long plid);
254 
255     public long getPortletGroupId(Layout layout);
256 
257     public long getPortletGroupId(HttpServletRequest request);
258 
259     public long getPortletGroupId(ActionRequest actionRequest);
260 
261     public long getPortletGroupId(RenderRequest renderRequest);
262 
263     public String getPortletId(HttpServletRequest request);
264 
265     public String getPortletId(ActionRequest actionRequest);
266 
267     public String getPortletId(RenderRequest renderRequest);
268 
269     public String getPortletNamespace(String portletId);
270 
271     public String getPortletTitle(
272         String portletId, long companyId, String languageId);
273 
274     public String getPortletTitle(
275         String portletId, long companyId, Locale locale);
276 
277     public String getPortletTitle(String portletId, User user);
278 
279     public String getPortletTitle(
280         Portlet portlet, long companyId, String languageId);
281 
282     public String getPortletTitle(
283         Portlet portlet, long companyId, Locale locale);
284 
285     public String getPortletTitle(Portlet portlet, User user);
286 
287     public String getPortletTitle(
288         Portlet portlet, ServletContext servletContext, Locale locale);
289 
290     public String getPortletXmlFileName()
291         throws PortalException, SystemException;
292 
293     public PortletPreferences getPreferences(HttpServletRequest request);
294 
295     public PreferencesValidator getPreferencesValidator(
296         Portlet portlet);
297 
298     public User getSelectedUser(HttpServletRequest request)
299         throws PortalException, RemoteException, SystemException;
300 
301     public User getSelectedUser(
302             HttpServletRequest request, boolean checkPermission)
303         throws PortalException, RemoteException, SystemException;
304 
305     public User getSelectedUser(ActionRequest actionRequest)
306         throws PortalException, RemoteException, SystemException;
307 
308     public User getSelectedUser(
309             ActionRequest actionRequest, boolean checkPermission)
310         throws PortalException, RemoteException, SystemException;
311 
312     public User getSelectedUser(RenderRequest renderRequest)
313         throws PortalException, RemoteException, SystemException;
314 
315     public User getSelectedUser(
316             RenderRequest renderRequest, boolean checkPermission)
317         throws PortalException, RemoteException, SystemException;
318 
319     public String getStrutsAction(HttpServletRequest request);
320 
321     public String[] getSystemCommunityRoles();
322 
323     public String[] getSystemGroups();
324 
325     public String[] getSystemOrganizationRoles();
326 
327     public String[] getSystemRoles();
328 
329     public UploadPortletRequest getUploadPortletRequest(
330         ActionRequest actionRequest);
331 
332     public UploadServletRequest getUploadServletRequest(
333         HttpServletRequest request);
334 
335     public Date getUptime();
336 
337     public String getURLWithSessionId(String url, String sessionId);
338 
339     public User getUser(HttpServletRequest request)
340         throws PortalException, SystemException;
341 
342     public User getUser(ActionRequest actionRequest)
343         throws PortalException, SystemException;
344 
345     public User getUser(RenderRequest renderRequest)
346         throws PortalException, SystemException;
347 
348     public long getUserId(HttpServletRequest request);
349 
350     public long getUserId(ActionRequest actionRequest);
351 
352     public long getUserId(RenderRequest renderRequest);
353 
354     public String getUserName(long userId, String defaultUserName);
355 
356     public String getUserName(
357         long userId, String defaultUserName, String userAttribute);
358 
359     public String getUserName(
360         long userId, String defaultUserName, HttpServletRequest request);
361 
362     public String getUserName(
363         long userId, String defaultUserName, String userAttribute,
364         HttpServletRequest request);
365 
366     public String getUserPassword(HttpSession session);
367 
368     public String getUserPassword(HttpServletRequest request);
369 
370     public String getUserPassword(ActionRequest actionRequest);
371 
372     public String getUserPassword(RenderRequest renderRequest);
373 
374     public String getUserValue(long userId, String param, String defaultValue)
375         throws SystemException;
376 
377     public String getWidgetURL(Portlet portlet, ThemeDisplay themeDisplay);
378 
379     public boolean isMethodGet(PortletRequest portletRequest);
380 
381     public boolean isMethodPost(PortletRequest portletRequest);
382 
383     public boolean isLayoutFriendliable(Layout layout);
384 
385     public boolean isLayoutParentable(Layout layout);
386 
387     public boolean isLayoutParentable(String type);
388 
389     public boolean isLayoutSitemapable(Layout layout);
390 
391     public boolean isReservedParameter(String name);
392 
393     public boolean isSystemGroup(String groupName);
394 
395     public boolean isSystemRole(String roleName);
396 
397     public boolean isUpdateAvailable() throws PortalException, SystemException;
398 
399     public void renderPage(
400             StringBuilder sb, ServletContext servletContext,
401             HttpServletRequest request, HttpServletResponse response,
402             String path)
403         throws IOException, ServletException;
404 
405     public void renderPortlet(
406             StringBuilder sb, ServletContext servletContext,
407             HttpServletRequest request, HttpServletResponse response,
408             Portlet portlet, String queryString)
409         throws IOException, ServletException;
410 
411     public void renderPortlet(
412             StringBuilder sb, ServletContext servletContext,
413             HttpServletRequest request, HttpServletResponse response,
414             Portlet portlet, String queryString, String columnId,
415             Integer columnPos, Integer columnCount)
416         throws IOException, ServletException;
417 
418     public void renderPortlet(
419             StringBuilder sb, ServletContext servletContext,
420             HttpServletRequest request, HttpServletResponse response,
421             Portlet portlet, String queryString, String columnId,
422             Integer columnPos, Integer columnCount, String path)
423         throws IOException, ServletException;
424 
425     public void sendError(
426             Exception e, HttpServletRequest request,
427             HttpServletResponse response)
428         throws IOException, ServletException;
429 
430     public void sendError(
431             int status, Exception e, HttpServletRequest request,
432             HttpServletResponse response)
433         throws IOException, ServletException;
434 
435     public void sendError(
436             Exception e, ActionRequest actionRequest,
437             ActionResponse actionResponse)
438         throws IOException;
439 
440     public void sendError(
441             int status, Exception e, ActionRequest actionRequest,
442             ActionResponse actionResponse)
443         throws IOException;
444 
445     /**
446      * Sets the subtitle for a page. This is just a hint and can be overridden
447      * by subsequent calls. The last call to this method wins.
448      *
449      * @param       subtitle the subtitle for a page
450      * @param       req the HTTP servlet request
451      */
452     public void setPageSubtitle(String subtitle, HttpServletRequest request);
453 
454     /**
455      * Sets the whole title for a page. This is just a hint and can be
456      * overridden by subsequent calls. The last call to this method wins.
457      *
458      * @param       title the whole title for a page
459      * @param       req the HTTP servlet request
460      */
461     public void setPageTitle(String title, HttpServletRequest request);
462 
463     /**
464      * Sets the port obtained on the first request to the portal.
465      *
466      * @param       req the HTTP servlet request
467      */
468     public void setPortalPort(HttpServletRequest request);
469 
470     public void storePreferences(PortletPreferences prefs)
471         throws IOException, ValidatorException;
472 
473     public String transformCustomSQL(String sql);
474 
475     public PortletMode updatePortletMode(
476         String portletId, User user, Layout layout, PortletMode portletMode,
477         HttpServletRequest request);
478 
479     public WindowState updateWindowState(
480         String portletId, User user, Layout layout, WindowState windowState,
481         HttpServletRequest request);
482 
483 }