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