001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.util;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.portlet.LiferayPortletResponse;
020    import com.liferay.portal.kernel.upload.UploadPortletRequest;
021    import com.liferay.portal.kernel.upload.UploadServletRequest;
022    import com.liferay.portal.kernel.util.KeyValuePair;
023    import com.liferay.portal.model.BaseModel;
024    import com.liferay.portal.model.Company;
025    import com.liferay.portal.model.Layout;
026    import com.liferay.portal.model.LayoutSet;
027    import com.liferay.portal.model.Portlet;
028    import com.liferay.portal.model.Resource;
029    import com.liferay.portal.model.ResourcePermission;
030    import com.liferay.portal.model.User;
031    import com.liferay.portal.theme.ThemeDisplay;
032    import com.liferay.portlet.expando.model.ExpandoBridge;
033    import com.liferay.portlet.social.model.SocialEquityActionMapping;
034    
035    import java.io.IOException;
036    import java.io.Serializable;
037    
038    import java.util.Date;
039    import java.util.List;
040    import java.util.Locale;
041    import java.util.Map;
042    import java.util.Properties;
043    import java.util.TimeZone;
044    
045    import javax.portlet.ActionRequest;
046    import javax.portlet.ActionResponse;
047    import javax.portlet.PortletMode;
048    import javax.portlet.PortletPreferences;
049    import javax.portlet.PortletRequest;
050    import javax.portlet.PortletResponse;
051    import javax.portlet.PreferencesValidator;
052    import javax.portlet.RenderRequest;
053    import javax.portlet.RenderResponse;
054    import javax.portlet.ValidatorException;
055    import javax.portlet.WindowState;
056    
057    import javax.servlet.ServletContext;
058    import javax.servlet.ServletException;
059    import javax.servlet.http.HttpServletRequest;
060    import javax.servlet.http.HttpServletResponse;
061    import javax.servlet.http.HttpSession;
062    import javax.servlet.jsp.PageContext;
063    
064    /**
065     * @author Brian Wing Shun Chan
066     * @author Eduardo Lundgren
067     */
068    public interface Portal {
069    
070            public static final String FRIENDLY_URL_SEPARATOR = "/-/";
071    
072            public static final String PATH_IMAGE = "/image";
073    
074            public static final String PATH_MAIN = "/c";
075    
076            public static final String PATH_PORTAL_LAYOUT = "/portal/layout";
077    
078            public static final String PORTAL_REALM = "PortalRealm";
079    
080            public static final String PORTLET_XML_FILE_NAME_CUSTOM =
081                    "portlet-custom.xml";
082    
083            public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.xml";
084    
085            public static final String TEMP_OBFUSCATION_VALUE =
086                    "TEMP_OBFUSCATION_VALUE";
087    
088            /**
089             * Adds the description for a page. This appends to the existing page
090             * description.
091             */
092            public void addPageDescription(
093                    String description, HttpServletRequest request);
094    
095            /**
096             * Adds the keywords for a page. This appends to the existing page keywords.
097             */
098            public void addPageKeywords(String keywords, HttpServletRequest request);
099    
100            /**
101             * Adds the subtitle for a page. This appends to the existing page subtitle.
102             */
103            public void addPageSubtitle(String subtitle, HttpServletRequest request);
104    
105            /**
106             * Adds the whole title for a page. This appends to the existing page whole
107             * title.
108             */
109            public void addPageTitle(String title, HttpServletRequest request);
110    
111            public void addPortalPortEventListener(
112                    PortalPortEventListener portalPortEventListener);
113    
114            public void addPortletBreadcrumbEntry(
115                    HttpServletRequest request, String title, String url);
116    
117            public void addPortletDefaultResource(
118                            HttpServletRequest request, Portlet portlet)
119                    throws PortalException, SystemException;
120    
121            /**
122             * Adds preserved parameters such as doAsGroupId, doAsUserId,
123             * doAsUserLanguageId, and referrerPlid that should always be preserved as
124             * the user navigates through the portal. If doAsUser is <code>false</code>,
125             * then doAsUserId and doAsUserLanguageId will never be added.
126             */
127            public String addPreservedParameters(
128                    ThemeDisplay themeDisplay, Layout layout, String url, boolean doAsUser);
129    
130            /**
131             * Adds preserved parameters such as doAsGroupId, doAsUserId,
132             * doAsUserLanguageId, and referrerPlid that should always be preserved as
133             * the user navigates through the portal.
134             */
135            public String addPreservedParameters(
136                    ThemeDisplay themeDisplay, String url);
137    
138            public void clearRequestParameters(RenderRequest renderRequest);
139    
140            public void copyRequestParameters(
141                    ActionRequest actionRequest, ActionResponse actionResponse);
142    
143            public String escapeRedirect(String url);
144    
145            public String generateRandomKey(HttpServletRequest request, String input);
146    
147            public BaseModel<?> getBaseModel(Resource resource)
148                    throws PortalException, SystemException;
149    
150            public BaseModel<?> getBaseModel(ResourcePermission resourcePermission)
151                    throws PortalException, SystemException;
152    
153            public BaseModel<?> getBaseModel(String modelName, String primKey)
154                    throws PortalException, SystemException;
155    
156            public long getBasicAuthUserId(HttpServletRequest request)
157                    throws PortalException, SystemException;
158    
159            public long getBasicAuthUserId(HttpServletRequest request, long companyId)
160                    throws PortalException, SystemException;
161    
162            /**
163             * @deprecated {@link #getCDNHost(boolean)}
164             */
165            public String getCDNHost();
166    
167            public String getCDNHost(boolean secure);
168    
169            public String getCDNHostHttp();
170    
171            public String getCDNHostHttps();
172    
173            public String getClassName(long classNameId);
174    
175            public long getClassNameId(Class<?> classObj);
176    
177            public long getClassNameId(String value);
178    
179            public String getClassNamePortletId(String className);
180    
181            public String getCommunityLoginURL(ThemeDisplay themeDisplay)
182                    throws PortalException, SystemException;
183    
184            public String[] getCommunityPermissions(HttpServletRequest request);
185    
186            public String[] getCommunityPermissions(PortletRequest portletRequest);
187    
188            public Company getCompany(HttpServletRequest request)
189                    throws PortalException, SystemException;
190    
191            public Company getCompany(PortletRequest portletRequest)
192                    throws PortalException, SystemException;
193    
194            public long getCompanyId(HttpServletRequest requestuest);
195    
196            public long getCompanyId(PortletRequest portletRequest);
197    
198            public long[] getCompanyIds();
199    
200            public String getComputerAddress();
201    
202            public String getComputerName();
203    
204            public String getControlPanelCategory(
205                            String portletId, ThemeDisplay themeDisplay)
206                    throws SystemException;
207    
208            public String getControlPanelFullURL(
209                            long scopeGroupId, String ppid, Map<String, String[]> params)
210                    throws PortalException, SystemException;
211    
212            public List<Portlet> getControlPanelPortlets(
213                            String category, ThemeDisplay themeDisplay)
214                    throws SystemException;
215    
216            public String getCurrentCompleteURL(HttpServletRequest request);
217    
218            public String getCurrentURL(HttpServletRequest request);
219    
220            public String getCurrentURL(PortletRequest portletRequest);
221    
222            public String getCustomSQLFunctionIsNotNull();
223    
224            public String getCustomSQLFunctionIsNull();
225    
226            public Date getDate(int month, int day, int year);
227    
228            public Date getDate(
229                            int month, int day, int year, int hour, int min, PortalException pe)
230                    throws PortalException;
231    
232            public Date getDate(
233                            int month, int day, int year, int hour, int min, TimeZone timeZone,
234                            PortalException pe)
235                    throws PortalException;
236    
237            public Date getDate(int month, int day, int year, PortalException pe)
238                    throws PortalException;
239    
240            public Date getDate(
241                            int month, int day, int year, TimeZone timeZone, PortalException pe)
242                    throws PortalException;
243    
244            public long getDefaultCompanyId();
245    
246            public long getDigestAuthUserId(HttpServletRequest request)
247                    throws PortalException, SystemException;
248    
249            public Map<String, Serializable> getExpandoBridgeAttributes(
250                            ExpandoBridge expandoBridge, PortletRequest portletRequest)
251                    throws PortalException, SystemException;
252    
253            public String getFacebookURL(
254                            Portlet portlet, String facebookCanvasPageURL,
255                            ThemeDisplay themeDisplay)
256                    throws PortalException, SystemException;
257    
258            public String getFirstPageLayoutTypes(PageContext pageContext);
259    
260            public String getGlobalLibDir();
261    
262            public String getGoogleGadgetURL(
263                            Portlet portlet, ThemeDisplay themeDisplay)
264                    throws PortalException, SystemException;
265    
266            public String[] getGuestPermissions(HttpServletRequest request);
267    
268            public String[] getGuestPermissions(PortletRequest portletRequest);
269    
270            public String getHomeURL(HttpServletRequest request)
271                    throws PortalException, SystemException;
272    
273            public String getHost(HttpServletRequest request);
274    
275            public String getHost(PortletRequest portletRequest);
276    
277            public HttpServletRequest getHttpServletRequest(
278                    PortletRequest portletRequest);
279    
280            public HttpServletResponse getHttpServletResponse(
281                    PortletResponse portletResponse);
282    
283            public String getJsSafePortletId(String portletId) ;
284    
285            public String getLayoutActualURL(Layout layout);
286    
287            public String getLayoutActualURL(Layout layout, String mainPath);
288    
289            public String getLayoutActualURL(
290                            long groupId, boolean privateLayout, String mainPath,
291                            String friendlyURL)
292                    throws PortalException, SystemException;
293    
294            public String getLayoutActualURL(
295                            long groupId, boolean privateLayout, String mainPath,
296                            String friendlyURL, Map<String, String[]> params,
297                            Map<String, Object> requestContext)
298                    throws PortalException, SystemException;
299    
300            public String getLayoutEditPage(Layout layout);
301    
302            public String getLayoutEditPage(String type);
303    
304            public String getLayoutFriendlyURL(
305                            Layout layout, ThemeDisplay themeDisplay)
306                    throws PortalException, SystemException;
307    
308            public String getLayoutFriendlyURL(
309                            Layout layout, ThemeDisplay themeDisplay, Locale locale)
310                    throws PortalException, SystemException;
311    
312            public String getLayoutFullURL(Layout layout, ThemeDisplay themeDisplay)
313                    throws PortalException, SystemException;
314    
315            public String getLayoutFullURL(
316                            Layout layout, ThemeDisplay themeDisplay, boolean doAsUser)
317                    throws PortalException, SystemException;
318    
319            public String getLayoutFullURL(long groupId, String portletId)
320                    throws PortalException, SystemException;
321    
322            public String getLayoutFullURL(ThemeDisplay themeDisplay)
323                    throws PortalException, SystemException;
324    
325            public String getLayoutSetFriendlyURL(
326                            LayoutSet layoutSet, ThemeDisplay themeDisplay)
327                    throws PortalException, SystemException;
328    
329            public String getLayoutTarget(Layout layout);
330    
331            public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay)
332                    throws PortalException, SystemException;
333    
334            public String getLayoutURL(
335                            Layout layout, ThemeDisplay themeDisplay, boolean doAsUser)
336                    throws PortalException, SystemException;
337    
338            public String getLayoutURL(ThemeDisplay themeDisplay)
339                    throws PortalException, SystemException;
340    
341            public String getLayoutViewPage(Layout layout);
342    
343            public String getLayoutViewPage(String type);
344    
345            public LiferayPortletResponse getLiferayPortletResponse(
346                    PortletResponse portletResponse);
347    
348            public Locale getLocale(HttpServletRequest request);
349    
350            public Locale getLocale(RenderRequest renderRequest);
351    
352            public String getNetvibesURL(Portlet portlet, ThemeDisplay themeDisplay)
353                    throws PortalException, SystemException;
354    
355            public HttpServletRequest getOriginalServletRequest(
356                    HttpServletRequest request);
357    
358            public long getParentGroupId(long scopeGroupId)
359                    throws SystemException, PortalException;
360    
361            public String getPathContext();
362    
363            public String getPathFriendlyURLPrivateGroup();
364    
365            public String getPathFriendlyURLPrivateUser();
366    
367            public String getPathFriendlyURLPublic();
368    
369            public String getPathImage();
370    
371            public String getPathMain();
372    
373            public long getPlidFromFriendlyURL(long companyId, String friendlyURL);
374    
375            public long getPlidFromPortletId(
376                            long groupId, boolean privateLayout, String portletId)
377                    throws PortalException, SystemException;
378    
379            public long getPlidFromPortletId(long groupId, String portletId)
380                    throws PortalException, SystemException;
381    
382            public String getPortalLibDir();
383    
384            public int getPortalPort();
385    
386            public Properties getPortalProperties();
387    
388            public String getPortalURL(HttpServletRequest request);
389    
390            public String getPortalURL(HttpServletRequest request, boolean secure);
391    
392            public String getPortalURL(PortletRequest portletRequest);
393    
394            public String getPortalURL(PortletRequest portletRequest, boolean secure);
395    
396            public String getPortalURL(
397                    String serverName, int serverPort, boolean secure);
398    
399            public String getPortalURL(ThemeDisplay themeDisplay)
400                    throws PortalException, SystemException;
401    
402            public String getPortalWebDir();
403    
404            public List<KeyValuePair> getPortletBreadcrumbList(
405                    HttpServletRequest request);
406    
407            public String getPortletDescription(
408                    Portlet portlet, ServletContext servletContext, Locale locale);
409    
410            public String getPortletDescription(Portlet portlet, User user);
411    
412            public String getPortletDescription(String portletId, Locale locale);
413    
414            public String getPortletDescription(String portletId, String languageId);
415    
416            public String getPortletDescription(String portletId, User user);
417    
418            public String getPortletId(HttpServletRequest request);
419    
420            public String getPortletId(PortletRequest portletRequest);
421    
422            public String getPortletNamespace(String portletId);
423    
424            public String getPortletTitle(Portlet portlet, Locale locale);
425    
426            public String getPortletTitle(
427                    Portlet portlet, ServletContext servletContext, Locale locale);
428    
429            public String getPortletTitle(Portlet portlet, String languageId);
430    
431            public String getPortletTitle(Portlet portlet, User user);
432    
433            public String getPortletTitle(RenderResponse renderResponse);
434    
435            public String getPortletTitle(String portletId, Locale locale);
436    
437            public String getPortletTitle(String portletId, String languageId);
438    
439            public String getPortletTitle(String portletId, User user);
440    
441            public String getPortletXmlFileName() throws SystemException;
442    
443            public PortletPreferences getPreferences(HttpServletRequest request);
444    
445            public PreferencesValidator getPreferencesValidator(
446                    Portlet portlet);
447    
448            public long getScopeGroupId(HttpServletRequest request)
449                    throws PortalException, SystemException;
450    
451            public long getScopeGroupId(HttpServletRequest request, String portletId)
452                    throws PortalException, SystemException;
453    
454            public long getScopeGroupId(Layout layout);
455    
456            public long getScopeGroupId(Layout layout, String portletId);
457    
458            public long getScopeGroupId(long plid);
459    
460            public long getScopeGroupId(PortletRequest portletRequest)
461                    throws PortalException, SystemException;
462    
463            public User getSelectedUser(HttpServletRequest request)
464                    throws PortalException, SystemException;
465    
466            public User getSelectedUser(
467                            HttpServletRequest request, boolean checkPermission)
468                    throws PortalException, SystemException;
469    
470            public User getSelectedUser(PortletRequest portletRequest)
471                    throws PortalException, SystemException;
472    
473            public User getSelectedUser(
474                            PortletRequest portletRequest, boolean checkPermission)
475                    throws PortalException, SystemException;
476    
477            public ServletContext getServletContext(
478                    Portlet portlet, ServletContext servletContext);
479    
480            public SocialEquityActionMapping getSocialEquityActionMapping(
481                    String name, String actionId);
482    
483            public List<SocialEquityActionMapping> getSocialEquityActionMappings(
484                    String name);
485    
486            public String[] getSocialEquityClassNames();
487    
488            public String getStaticResourceURL(
489                    HttpServletRequest request, String uri);
490    
491            public String getStaticResourceURL(
492                    HttpServletRequest request, String uri, long timestamp);
493    
494            public String getStaticResourceURL(
495                    HttpServletRequest request, String uri, String queryString);
496    
497            public String getStaticResourceURL(
498                    HttpServletRequest request, String uri, String queryString,
499                    long timestamp);
500    
501            public String getStrutsAction(HttpServletRequest request);
502    
503            public String[] getSystemCommunityRoles();
504    
505            public String[] getSystemGroups();
506    
507            public String[] getSystemOrganizationRoles();
508    
509            public String[] getSystemRoles();
510    
511            public UploadServletRequest getUploadServletRequest(
512                    HttpServletRequest request);
513    
514            public UploadPortletRequest getUploadPortletRequest(
515                    PortletRequest portletRequest);
516    
517            public Date getUptime();
518    
519            public String getURLWithSessionId(String url, String sessionId);
520    
521            public User getUser(HttpServletRequest request)
522                    throws PortalException, SystemException;
523    
524            public User getUser(PortletRequest portletRequest)
525                    throws PortalException, SystemException;
526    
527            public long getUserId(HttpServletRequest request);
528    
529            public long getUserId(PortletRequest portletRequest);
530    
531            public String getUserName(long userId, String defaultUserName);
532    
533            public String getUserName(
534                    long userId, String defaultUserName, HttpServletRequest request);
535    
536            public String getUserName(
537                    long userId, String defaultUserName, String userAttribute);
538    
539            public String getUserName(
540                    long userId, String defaultUserName, String userAttribute,
541                    HttpServletRequest request);
542    
543            public String getUserPassword(HttpServletRequest request);
544    
545            public String getUserPassword(HttpSession session);
546    
547            public String getUserPassword(PortletRequest portletRequest);
548    
549            public String getUserValue(long userId, String param, String defaultValue)
550                    throws SystemException;
551    
552            public long getValidUserId(long companyId, long userId)
553                    throws PortalException, SystemException;
554    
555            public String getWidgetURL(Portlet portlet, ThemeDisplay themeDisplay)
556                    throws PortalException, SystemException;
557    
558            public boolean isAllowAddPortletDefaultResource(
559                            HttpServletRequest request, Portlet portlet)
560                    throws PortalException, SystemException;
561    
562            public boolean isCommunityAdmin(User user, long groupId) throws Exception;
563    
564            public boolean isCommunityOwner(User user, long groupId) throws Exception;
565    
566            public boolean isCompanyAdmin(User user) throws Exception;
567    
568            public boolean isControlPanelPortlet(
569                            String portletId, String category, ThemeDisplay themeDisplay)
570                    throws SystemException;
571    
572            public boolean isControlPanelPortlet(
573                            String portletId, ThemeDisplay themeDisplay)
574                    throws SystemException;
575    
576            public boolean isLayoutFirstPageable(Layout layout);
577    
578            public boolean isLayoutFirstPageable(String type);
579    
580            public boolean isLayoutFriendliable(Layout layout);
581    
582            public boolean isLayoutFriendliable(String type);
583    
584            public boolean isLayoutParentable(Layout layout);
585    
586            public boolean isLayoutParentable(String type);
587    
588            public boolean isLayoutSitemapable(Layout layout);
589    
590            public boolean isMethodGet(PortletRequest portletRequest);
591    
592            public boolean isMethodPost(PortletRequest portletRequest);
593    
594            public boolean isOmniadmin(long userId);
595    
596            public boolean isReservedParameter(String name);
597    
598            public boolean isSystemGroup(String groupName);
599    
600            public boolean isSystemRole(String roleName);
601    
602            public boolean isUpdateAvailable() throws SystemException;
603    
604            public boolean isValidResourceId(String resourceId);
605    
606            public void removePortalPortEventListener(
607                    PortalPortEventListener portalPortEventListener);
608    
609            public String renderPage(
610                            ServletContext servletContext, HttpServletRequest request,
611                            HttpServletResponse response, String path)
612                    throws IOException, ServletException;
613    
614            public String renderPortlet(
615                            ServletContext servletContext, HttpServletRequest request,
616                            HttpServletResponse response, Portlet portlet, String queryString,
617                            boolean writeOutput)
618                    throws IOException, ServletException;
619    
620            public String renderPortlet(
621                            ServletContext servletContext, HttpServletRequest request,
622                            HttpServletResponse response, Portlet portlet, String queryString,
623                            String columnId, Integer columnPos, Integer columnCount,
624                            boolean writeOutput)
625                    throws IOException, ServletException;
626    
627            public String renderPortlet(
628                            ServletContext servletContext, HttpServletRequest request,
629                            HttpServletResponse response, Portlet portlet, String queryString,
630                            String columnId, Integer columnPos, Integer columnCount,
631                            String path, boolean writeOutput)
632                    throws IOException, ServletException;
633    
634            public void sendError(
635                            Exception e, ActionRequest actionRequest,
636                            ActionResponse actionResponse)
637                    throws IOException;
638    
639            public void sendError(
640                            Exception e, HttpServletRequest request,
641                            HttpServletResponse response)
642                    throws IOException, ServletException;
643    
644            public void sendError(
645                            int status, Exception e, ActionRequest actionRequest,
646                            ActionResponse actionResponse)
647                    throws IOException;
648    
649            public void sendError(
650                            int status, Exception e, HttpServletRequest request,
651                            HttpServletResponse response)
652                    throws IOException, ServletException;
653    
654            /**
655             * Sets the description for a page. This overrides the existing page
656             * description.
657             */
658            public void setPageDescription(
659                    String description, HttpServletRequest request);
660    
661            /**
662             * Sets the keywords for a page. This overrides the existing page keywords.
663             */
664            public void setPageKeywords(String keywords, HttpServletRequest request);
665    
666            /**
667             * Sets the subtitle for a page. This overrides the existing page subtitle.
668             */
669            public void setPageSubtitle(String subtitle, HttpServletRequest request);
670    
671            /**
672             * Sets the whole title for a page. This overrides the existing page whole
673             * title.
674             */
675            public void setPageTitle(String title, HttpServletRequest request);
676    
677            /**
678             * Sets the port obtained on the first request to the portal.
679             */
680            public void setPortalPort(HttpServletRequest request);
681    
682            public void storePreferences(PortletPreferences preferences)
683                    throws IOException, ValidatorException;
684    
685            public String transformCustomSQL(String sql);
686    
687            public PortletMode updatePortletMode(
688                    String portletId, User user, Layout layout, PortletMode portletMode,
689                    HttpServletRequest request);
690    
691            public WindowState updateWindowState(
692                    String portletId, User user, Layout layout, WindowState windowState,
693                    HttpServletRequest request);
694    
695    }