1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.util;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.upload.UploadPortletRequest;
20  import com.liferay.portal.kernel.upload.UploadServletRequest;
21  import com.liferay.portal.kernel.util.KeyValuePair;
22  import com.liferay.portal.model.BaseModel;
23  import com.liferay.portal.model.Company;
24  import com.liferay.portal.model.Layout;
25  import com.liferay.portal.model.LayoutSet;
26  import com.liferay.portal.model.Portlet;
27  import com.liferay.portal.model.Resource;
28  import com.liferay.portal.model.ResourcePermission;
29  import com.liferay.portal.model.User;
30  import com.liferay.portal.theme.ThemeDisplay;
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  
33  import java.io.IOException;
34  import java.io.Serializable;
35  
36  import java.util.Date;
37  import java.util.List;
38  import java.util.Locale;
39  import java.util.Map;
40  import java.util.Properties;
41  import java.util.Set;
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  import javax.servlet.jsp.PageContext;
61  
62  /**
63   * <a href="Portal.java.html"><b><i>View Source</i></b></a>
64   *
65   * @author Brian Wing Shun Chan
66   * @author Eduardo Lundgren
67   */
68  public interface Portal {
69  
70      public static final String FRIENDLY_URL_SEPARATOR = "/-/";
71  
72      public static final String PATH_IMAGE = "/image";
73  
74      public static final String PATH_MAIN = "/c";
75  
76      public static final String PATH_PORTAL_LAYOUT = "/portal/layout";
77  
78      public static final String PORTLET_XML_FILE_NAME_CUSTOM =
79          "portlet-custom.xml";
80  
81      public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.xml";
82  
83      /**
84       * Adds the description for a page. This appends to the existing page
85       * description.
86       */
87      public void addPageDescription(
88          String description, HttpServletRequest request);
89  
90      /**
91       * Adds the keywords for a page. This appends to the existing page keywords.
92       */
93      public void addPageKeywords(String keywords, HttpServletRequest request);
94  
95      /**
96       * Adds the subtitle for a page. This appends to the existing page subtitle.
97       */
98      public void addPageSubtitle(String subtitle, HttpServletRequest request);
99  
100     /**
101      * Adds the whole title for a page. This appends to the existing page whole
102      * title.
103      */
104     public void addPageTitle(String title, HttpServletRequest request);
105 
106     public void addPortletBreadcrumbEntry(
107         HttpServletRequest request, String title, String url);
108 
109     public void clearRequestParameters(RenderRequest renderRequest);
110 
111     public void copyRequestParameters(
112         ActionRequest actionRequest, ActionResponse actionResponse);
113 
114     public String escapeRedirect(String url);
115 
116     public String generateRandomKey(HttpServletRequest request, String input);
117 
118     public BaseModel<?> getBaseModel(Resource resource)
119         throws PortalException, SystemException;
120 
121     public BaseModel<?> getBaseModel(ResourcePermission resourcePermission)
122         throws PortalException, SystemException;
123 
124     public BaseModel<?> getBaseModel(String modelName, String primKey)
125         throws PortalException, SystemException;
126 
127     public long getBasicAuthUserId(HttpServletRequest request)
128         throws PortalException, SystemException;
129 
130     public long getBasicAuthUserId(HttpServletRequest request, long companyId)
131         throws PortalException, SystemException;
132 
133     /**
134      * @deprecated {@link #getCDNHost(boolean)}
135      */
136     public String getCDNHost();
137 
138     public String getCDNHost(boolean secure);
139 
140     public String getCDNHostHttp();
141 
142     public String getCDNHostHttps();
143 
144     public String getClassName(long classNameId);
145 
146     public long getClassNameId(Class<?> classObj);
147 
148     public long getClassNameId(String value);
149 
150     public String getClassNamePortletId(String className);
151 
152     public String getCommunityLoginURL(ThemeDisplay themeDisplay)
153         throws PortalException, SystemException;
154 
155     public String[] getCommunityPermissions(HttpServletRequest request);
156 
157     public String[] getCommunityPermissions(PortletRequest portletRequest);
158 
159     public Company getCompany(HttpServletRequest request)
160         throws PortalException, SystemException;
161 
162     public Company getCompany(PortletRequest portletRequest)
163         throws PortalException, SystemException;
164 
165     public long getCompanyId(HttpServletRequest requestuest);
166 
167     public long getCompanyId(PortletRequest portletRequest);
168 
169     public long[] getCompanyIds();
170 
171     public String getComputerAddress();
172 
173     public String getComputerName();
174 
175     public String getControlPanelCategory(
176             String portletId, ThemeDisplay themeDisplay)
177         throws SystemException;
178 
179     public String getControlPanelFullURL(
180             long scopeGroupId, String ppid, Map<String, String[]> params)
181         throws PortalException, SystemException;
182 
183     public List<Portlet> getControlPanelPortlets(
184             String category, ThemeDisplay themeDisplay)
185         throws SystemException;
186 
187     public String getCurrentCompleteURL(HttpServletRequest request);
188 
189     public String getCurrentURL(HttpServletRequest request);
190 
191     public String getCurrentURL(PortletRequest portletRequest);
192 
193     public String getCustomSQLFunctionIsNotNull();
194 
195     public String getCustomSQLFunctionIsNull();
196 
197     public Date getDate(
198             int month, int day, int year, int hour, int min, PortalException pe)
199         throws PortalException;
200 
201     public Date getDate(
202             int month, int day, int year, int hour, int min, TimeZone timeZone,
203             PortalException pe)
204         throws PortalException;
205 
206     public Date getDate(int month, int day, int year, PortalException pe)
207         throws PortalException;
208 
209     public Date getDate(
210             int month, int day, int year, TimeZone timeZone, PortalException pe)
211         throws PortalException;
212 
213     public long getDefaultCompanyId();
214 
215     public Map<String, Serializable> getExpandoBridgeAttributes(
216             ExpandoBridge expandoBridge, PortletRequest portletRequest)
217         throws PortalException, SystemException;
218 
219     public String getFirstPageLayoutTypes(PageContext pageContext);
220 
221     public String getGlobalLibDir();
222 
223     public String getGoogleGadgetURL(
224             Portlet portlet, ThemeDisplay themeDisplay)
225         throws PortalException, SystemException;
226 
227     public String[] getGuestPermissions(HttpServletRequest request);
228 
229     public String[] getGuestPermissions(PortletRequest portletRequest);
230 
231     public String getHomeURL(HttpServletRequest request)
232         throws PortalException, SystemException;
233 
234     public String getHost(HttpServletRequest request);
235 
236     public String getHost(PortletRequest portletRequest);
237 
238     public HttpServletRequest getHttpServletRequest(
239         PortletRequest portletRequest);
240 
241     public HttpServletResponse getHttpServletResponse(
242         PortletResponse portletResponse);
243 
244     public String getJsSafePortletId(String portletId) ;
245 
246     public String getLayoutActualURL(Layout layout);
247 
248     public String getLayoutActualURL(Layout layout, String mainPath);
249 
250     public String getLayoutActualURL(
251             long groupId, boolean privateLayout, String mainPath,
252             String friendlyURL)
253         throws PortalException, SystemException;
254 
255     public String getLayoutActualURL(
256             long groupId, boolean privateLayout, String mainPath,
257             String friendlyURL, Map<String, String[]> params)
258         throws PortalException, SystemException;
259 
260     public String getLayoutEditPage(Layout layout);
261 
262     public String getLayoutEditPage(String type);
263 
264     public String getLayoutFriendlyURL(
265             Layout layout, ThemeDisplay themeDisplay)
266         throws PortalException, SystemException;
267 
268     public String getLayoutFriendlyURL(
269             Layout layout, ThemeDisplay themeDisplay, Locale locale)
270         throws PortalException, SystemException;
271 
272     public String getLayoutFullURL(Layout layout, ThemeDisplay themeDisplay)
273         throws PortalException, SystemException;
274 
275     public String getLayoutFullURL(
276             Layout layout, ThemeDisplay themeDisplay, boolean doAsUser)
277         throws PortalException, SystemException;
278 
279     public String getLayoutFullURL(long groupId, String portletId)
280         throws PortalException, SystemException;
281 
282     public String getLayoutFullURL(ThemeDisplay themeDisplay)
283         throws PortalException, SystemException;
284 
285     public String getLayoutSetFriendlyURL(
286             LayoutSet layoutSet, ThemeDisplay themeDisplay)
287         throws PortalException, SystemException;
288 
289     public String getLayoutTarget(Layout layout);
290 
291     public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay)
292         throws PortalException, SystemException;
293 
294     public String getLayoutURL(
295             Layout layout, ThemeDisplay themeDisplay, boolean doAsUser)
296         throws PortalException, SystemException;
297 
298     public String getLayoutURL(ThemeDisplay themeDisplay)
299         throws PortalException, SystemException;
300 
301     public String getLayoutViewPage(Layout layout);
302 
303     public String getLayoutViewPage(String type);
304 
305     public Locale getLocale(HttpServletRequest request);
306 
307     public Locale getLocale(RenderRequest renderRequest);
308 
309     public String getNetvibesURL(Portlet portlet, ThemeDisplay themeDisplay)
310         throws PortalException, SystemException;
311 
312     public HttpServletRequest getOriginalServletRequest(
313         HttpServletRequest request);
314 
315     public long getParentGroupId(long scopeGroupId)
316         throws SystemException, PortalException;
317 
318     public String getPathContext();
319 
320     public String getPathFriendlyURLPrivateGroup();
321 
322     public String getPathFriendlyURLPrivateUser();
323 
324     public String getPathFriendlyURLPublic();
325 
326     public String getPathImage();
327 
328     public String getPathMain();
329 
330     public long getPlidFromFriendlyURL(long companyId, String friendlyURL);
331 
332     public long getPlidFromPortletId(
333             long groupId, boolean privateLayout, String portletId)
334         throws PortalException, SystemException;
335 
336     public long getPlidFromPortletId(long groupId, String portletId)
337         throws PortalException, SystemException;
338 
339     public String getPortalLibDir();
340 
341     public int getPortalPort();
342 
343     public Properties getPortalProperties();
344 
345     public String getPortalURL(HttpServletRequest request);
346 
347     public String getPortalURL(HttpServletRequest request, boolean secure);
348 
349     public String getPortalURL(PortletRequest portletRequest);
350 
351     public String getPortalURL(PortletRequest portletRequest, boolean secure);
352 
353     public String getPortalURL(
354         String serverName, int serverPort, boolean secure);
355 
356     public String getPortalURL(ThemeDisplay themeDisplay)
357         throws PortalException, SystemException;
358 
359     public String getPortalWebDir();
360 
361     public Set<String> getPortletAddDefaultResourceCheckWhitelist();
362 
363     public List<KeyValuePair> getPortletBreadcrumbList(
364         HttpServletRequest request);
365 
366     public String getPortletDescription(
367         Portlet portlet, ServletContext servletContext, Locale locale);
368 
369     public String getPortletDescription(Portlet portlet, User user);
370 
371     public String getPortletDescription(String portletId, Locale locale);
372 
373     public String getPortletDescription(String portletId, String languageId);
374 
375     public String getPortletDescription(String portletId, User user);
376 
377     public Object[] getPortletFriendlyURLMapper(
378             long groupId, boolean privateLayout, String url)
379         throws PortalException, SystemException;
380 
381     public Object[] getPortletFriendlyURLMapper(
382             long groupId, boolean privateLayout, String url,
383             Map<String, String[]> params)
384         throws PortalException, SystemException;
385 
386     public String getPortletId(HttpServletRequest request);
387 
388     public String getPortletId(PortletRequest portletRequest);
389 
390     public String getPortletNamespace(String portletId);
391 
392     public String getPortletTitle(Portlet portlet, Locale locale);
393 
394     public String getPortletTitle(
395         Portlet portlet, ServletContext servletContext, Locale locale);
396 
397     public String getPortletTitle(Portlet portlet, String languageId);
398 
399     public String getPortletTitle(Portlet portlet, User user);
400 
401     public String getPortletTitle(String portletId, Locale locale);
402 
403     public String getPortletTitle(String portletId, String languageId);
404 
405     public String getPortletTitle(String portletId, User user);
406 
407     public String getPortletXmlFileName() throws SystemException;
408 
409     public PortletPreferences getPreferences(HttpServletRequest request);
410 
411     public PreferencesValidator getPreferencesValidator(
412         Portlet portlet);
413 
414     public long getScopeGroupId(HttpServletRequest request)
415         throws PortalException, SystemException;
416 
417     public long getScopeGroupId(HttpServletRequest request, String portletId)
418         throws PortalException, SystemException;
419 
420     public long getScopeGroupId(Layout layout);
421 
422     public long getScopeGroupId(Layout layout, String portletId);
423 
424     public long getScopeGroupId(long plid);
425 
426     public long getScopeGroupId(PortletRequest portletRequest)
427         throws PortalException, SystemException;
428 
429     public User getSelectedUser(HttpServletRequest request)
430         throws PortalException, SystemException;
431 
432     public User getSelectedUser(
433             HttpServletRequest request, boolean checkPermission)
434         throws PortalException, SystemException;
435 
436     public User getSelectedUser(PortletRequest portletRequest)
437         throws PortalException, SystemException;
438 
439     public User getSelectedUser(
440             PortletRequest portletRequest, boolean checkPermission)
441         throws PortalException, SystemException;
442 
443     public ServletContext getServletContext(
444         Portlet portlet, ServletContext servletContext);
445 
446     public String getStaticResourceURL(
447         HttpServletRequest request, String uri);
448 
449     public String getStaticResourceURL(
450         HttpServletRequest request, String uri, long timestamp);
451 
452     public String getStaticResourceURL(
453         HttpServletRequest request, String uri, String queryString);
454 
455     public String getStaticResourceURL(
456         HttpServletRequest request, String uri, String queryString,
457         long timestamp);
458 
459     public String getStrutsAction(HttpServletRequest request);
460 
461     public String[] getSystemCommunityRoles();
462 
463     public String[] getSystemGroups();
464 
465     public String[] getSystemOrganizationRoles();
466 
467     public String[] getSystemRoles();
468 
469     public UploadServletRequest getUploadServletRequest(
470         HttpServletRequest request);
471 
472     public UploadPortletRequest getUploadPortletRequest(
473         PortletRequest portletRequest);
474 
475     public Date getUptime();
476 
477     public String getURLWithSessionId(String url, String sessionId);
478 
479     public User getUser(HttpServletRequest request)
480         throws PortalException, SystemException;
481 
482     public User getUser(PortletRequest portletRequest)
483         throws PortalException, SystemException;
484 
485     public long getUserId(HttpServletRequest request);
486 
487     public long getUserId(PortletRequest portletRequest);
488 
489     public String getUserName(long userId, String defaultUserName);
490 
491     public String getUserName(
492         long userId, String defaultUserName, HttpServletRequest request);
493 
494     public String getUserName(
495         long userId, String defaultUserName, String userAttribute);
496 
497     public String getUserName(
498         long userId, String defaultUserName, String userAttribute,
499         HttpServletRequest request);
500 
501     public String getUserPassword(HttpServletRequest request);
502 
503     public String getUserPassword(HttpSession session);
504 
505     public String getUserPassword(PortletRequest portletRequest);
506 
507     public String getUserValue(long userId, String param, String defaultValue)
508         throws SystemException;
509 
510     public long getValidUserId(long companyId, long userId)
511         throws PortalException, SystemException;
512 
513     public String getWidgetURL(Portlet portlet, ThemeDisplay themeDisplay)
514         throws PortalException, SystemException;
515 
516     public boolean isLayoutFirstPageable(Layout layout);
517 
518     public boolean isLayoutFirstPageable(String type);
519 
520     public boolean isLayoutFriendliable(Layout layout);
521 
522     public boolean isLayoutFriendliable(String type);
523 
524     public boolean isLayoutParentable(Layout layout);
525 
526     public boolean isLayoutParentable(String type);
527 
528     public boolean isLayoutSitemapable(Layout layout);
529 
530     public boolean isMethodGet(PortletRequest portletRequest);
531 
532     public boolean isMethodPost(PortletRequest portletRequest);
533 
534     public boolean isReservedParameter(String name);
535 
536     public boolean isSystemGroup(String groupName);
537 
538     public boolean isSystemRole(String roleName);
539 
540     public boolean isUpdateAvailable() throws SystemException;
541 
542     public String renderPage(
543             ServletContext servletContext, HttpServletRequest request,
544             HttpServletResponse response, String path)
545         throws IOException, ServletException;
546 
547     public String renderPortlet(
548             ServletContext servletContext, HttpServletRequest request,
549             HttpServletResponse response, Portlet portlet, String queryString,
550             boolean writeOutput)
551         throws IOException, ServletException;
552 
553     public String renderPortlet(
554             ServletContext servletContext, HttpServletRequest request,
555             HttpServletResponse response, Portlet portlet, String queryString,
556             String columnId, Integer columnPos, Integer columnCount,
557             boolean writeOutput)
558         throws IOException, ServletException;
559 
560     public String renderPortlet(
561             ServletContext servletContext, HttpServletRequest request,
562             HttpServletResponse response, Portlet portlet, String queryString,
563             String columnId, Integer columnPos, Integer columnCount,
564             String path, boolean writeOutput)
565         throws IOException, ServletException;
566 
567     public void sendError(
568             Exception e, ActionRequest actionRequest,
569             ActionResponse actionResponse)
570         throws IOException;
571 
572     public void sendError(
573             Exception e, HttpServletRequest request,
574             HttpServletResponse response)
575         throws IOException, ServletException;
576 
577     public void sendError(
578             int status, Exception e, ActionRequest actionRequest,
579             ActionResponse actionResponse)
580         throws IOException;
581 
582     public void sendError(
583             int status, Exception e, HttpServletRequest request,
584             HttpServletResponse response)
585         throws IOException, ServletException;
586 
587     /**
588      * Sets the description for a page. This overrides the existing page
589      * description.
590      */
591     public void setPageDescription(
592         String description, HttpServletRequest request);
593 
594     /**
595      * Sets the keywords for a page. This overrides the existing page keywords.
596      */
597     public void setPageKeywords(String keywords, HttpServletRequest request);
598 
599     /**
600      * Sets the subtitle for a page. This overrides the existing page subtitle.
601      */
602     public void setPageSubtitle(String subtitle, HttpServletRequest request);
603 
604     /**
605      * Sets the whole title for a page. This overrides the existing page whole
606      * title.
607      */
608     public void setPageTitle(String title, HttpServletRequest request);
609 
610     /**
611      * Sets the port obtained on the first request to the portal.
612      */
613     public void setPortalPort(HttpServletRequest request);
614 
615     public void storePreferences(PortletPreferences preferences)
616         throws IOException, ValidatorException;
617 
618     public String transformCustomSQL(String sql);
619 
620     public PortletMode updatePortletMode(
621         String portletId, User user, Layout layout, PortletMode portletMode,
622         HttpServletRequest request);
623 
624     public WindowState updateWindowState(
625         String portletId, User user, Layout layout, WindowState windowState,
626         HttpServletRequest request);
627 
628 }