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