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