001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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 String getOuterPortletId(HttpServletRequest request);
359    
360            public long getParentGroupId(long scopeGroupId)
361                    throws SystemException, PortalException;
362    
363            public String getPathContext();
364    
365            public String getPathFriendlyURLPrivateGroup();
366    
367            public String getPathFriendlyURLPrivateUser();
368    
369            public String getPathFriendlyURLPublic();
370    
371            public String getPathImage();
372    
373            public String getPathMain();
374    
375            public long getPlidFromFriendlyURL(long companyId, String friendlyURL);
376    
377            public long getPlidFromPortletId(
378                            long groupId, boolean privateLayout, String portletId)
379                    throws PortalException, SystemException;
380    
381            public long getPlidFromPortletId(long groupId, String portletId)
382                    throws PortalException, SystemException;
383    
384            public String getPortalLibDir();
385    
386            public int getPortalPort();
387    
388            public Properties getPortalProperties();
389    
390            public String getPortalURL(HttpServletRequest request);
391    
392            public String getPortalURL(HttpServletRequest request, boolean secure);
393    
394            public String getPortalURL(PortletRequest portletRequest);
395    
396            public String getPortalURL(PortletRequest portletRequest, boolean secure);
397    
398            public String getPortalURL(
399                    String serverName, int serverPort, boolean secure);
400    
401            public String getPortalURL(ThemeDisplay themeDisplay)
402                    throws PortalException, SystemException;
403    
404            public String getPortalWebDir();
405    
406            public List<KeyValuePair> getPortletBreadcrumbList(
407                    HttpServletRequest request);
408    
409            public String getPortletDescription(
410                    Portlet portlet, ServletContext servletContext, Locale locale);
411    
412            public String getPortletDescription(Portlet portlet, User user);
413    
414            public String getPortletDescription(String portletId, Locale locale);
415    
416            public String getPortletDescription(String portletId, String languageId);
417    
418            public String getPortletDescription(String portletId, User user);
419    
420            public String getPortletId(HttpServletRequest request);
421    
422            public String getPortletId(PortletRequest portletRequest);
423    
424            public String getPortletNamespace(String portletId);
425    
426            public String getPortletTitle(Portlet portlet, Locale locale);
427    
428            public String getPortletTitle(
429                    Portlet portlet, ServletContext servletContext, Locale locale);
430    
431            public String getPortletTitle(Portlet portlet, String languageId);
432    
433            public String getPortletTitle(Portlet portlet, User user);
434    
435            public String getPortletTitle(RenderResponse renderResponse);
436    
437            public String getPortletTitle(String portletId, Locale locale);
438    
439            public String getPortletTitle(String portletId, String languageId);
440    
441            public String getPortletTitle(String portletId, User user);
442    
443            public String getPortletXmlFileName() throws SystemException;
444    
445            public PortletPreferences getPreferences(HttpServletRequest request);
446    
447            public PreferencesValidator getPreferencesValidator(
448                    Portlet portlet);
449    
450            public long getScopeGroupId(HttpServletRequest request)
451                    throws PortalException, SystemException;
452    
453            public long getScopeGroupId(HttpServletRequest request, String portletId)
454                    throws PortalException, SystemException;
455    
456            public long getScopeGroupId(Layout layout);
457    
458            public long getScopeGroupId(Layout layout, String portletId);
459    
460            public long getScopeGroupId(long plid);
461    
462            public long getScopeGroupId(PortletRequest portletRequest)
463                    throws PortalException, SystemException;
464    
465            public User getSelectedUser(HttpServletRequest request)
466                    throws PortalException, SystemException;
467    
468            public User getSelectedUser(
469                            HttpServletRequest request, boolean checkPermission)
470                    throws PortalException, SystemException;
471    
472            public User getSelectedUser(PortletRequest portletRequest)
473                    throws PortalException, SystemException;
474    
475            public User getSelectedUser(
476                            PortletRequest portletRequest, boolean checkPermission)
477                    throws PortalException, SystemException;
478    
479            public ServletContext getServletContext(
480                    Portlet portlet, ServletContext servletContext);
481    
482            public SocialEquityActionMapping getSocialEquityActionMapping(
483                    String name, String actionId);
484    
485            public List<SocialEquityActionMapping> getSocialEquityActionMappings(
486                    String name);
487    
488            public String[] getSocialEquityClassNames();
489    
490            public String getStaticResourceURL(
491                    HttpServletRequest request, String uri);
492    
493            public String getStaticResourceURL(
494                    HttpServletRequest request, String uri, long timestamp);
495    
496            public String getStaticResourceURL(
497                    HttpServletRequest request, String uri, String queryString);
498    
499            public String getStaticResourceURL(
500                    HttpServletRequest request, String uri, String queryString,
501                    long timestamp);
502    
503            public String getStrutsAction(HttpServletRequest request);
504    
505            public String[] getSystemCommunityRoles();
506    
507            public String[] getSystemGroups();
508    
509            public String[] getSystemOrganizationRoles();
510    
511            public String[] getSystemRoles();
512    
513            public UploadServletRequest getUploadServletRequest(
514                    HttpServletRequest request);
515    
516            public UploadPortletRequest getUploadPortletRequest(
517                    PortletRequest portletRequest);
518    
519            public Date getUptime();
520    
521            public String getURLWithSessionId(String url, String sessionId);
522    
523            public User getUser(HttpServletRequest request)
524                    throws PortalException, SystemException;
525    
526            public User getUser(PortletRequest portletRequest)
527                    throws PortalException, SystemException;
528    
529            public long getUserId(HttpServletRequest request);
530    
531            public long getUserId(PortletRequest portletRequest);
532    
533            public String getUserName(long userId, String defaultUserName);
534    
535            public String getUserName(
536                    long userId, String defaultUserName, HttpServletRequest request);
537    
538            public String getUserName(
539                    long userId, String defaultUserName, String userAttribute);
540    
541            public String getUserName(
542                    long userId, String defaultUserName, String userAttribute,
543                    HttpServletRequest request);
544    
545            public String getUserPassword(HttpServletRequest request);
546    
547            public String getUserPassword(HttpSession session);
548    
549            public String getUserPassword(PortletRequest portletRequest);
550    
551            public String getUserValue(long userId, String param, String defaultValue)
552                    throws SystemException;
553    
554            public long getValidUserId(long companyId, long userId)
555                    throws PortalException, SystemException;
556    
557            public String getWidgetURL(Portlet portlet, ThemeDisplay themeDisplay)
558                    throws PortalException, SystemException;
559    
560            public boolean isAllowAddPortletDefaultResource(
561                            HttpServletRequest request, Portlet portlet)
562                    throws PortalException, SystemException;
563    
564            public boolean isCommunityAdmin(User user, long groupId) throws Exception;
565    
566            public boolean isCommunityOwner(User user, long groupId) throws Exception;
567    
568            public boolean isCompanyAdmin(User user) throws Exception;
569    
570            public boolean isControlPanelPortlet(
571                            String portletId, String category, ThemeDisplay themeDisplay)
572                    throws SystemException;
573    
574            public boolean isControlPanelPortlet(
575                            String portletId, ThemeDisplay themeDisplay)
576                    throws SystemException;
577    
578            public boolean isLayoutFirstPageable(Layout layout);
579    
580            public boolean isLayoutFirstPageable(String type);
581    
582            public boolean isLayoutFriendliable(Layout layout);
583    
584            public boolean isLayoutFriendliable(String type);
585    
586            public boolean isLayoutParentable(Layout layout);
587    
588            public boolean isLayoutParentable(String type);
589    
590            public boolean isLayoutSitemapable(Layout layout);
591    
592            public boolean isMethodGet(PortletRequest portletRequest);
593    
594            public boolean isMethodPost(PortletRequest portletRequest);
595    
596            public boolean isOmniadmin(long userId);
597    
598            public boolean isReservedParameter(String name);
599    
600            public boolean isSystemGroup(String groupName);
601    
602            public boolean isSystemRole(String roleName);
603    
604            public boolean isUpdateAvailable() throws SystemException;
605    
606            public boolean isValidResourceId(String resourceId);
607    
608            public void removePortalPortEventListener(
609                    PortalPortEventListener portalPortEventListener);
610    
611            public String renderPage(
612                            ServletContext servletContext, HttpServletRequest request,
613                            HttpServletResponse response, String path)
614                    throws IOException, ServletException;
615    
616            public String renderPortlet(
617                            ServletContext servletContext, HttpServletRequest request,
618                            HttpServletResponse response, Portlet portlet, String queryString,
619                            boolean writeOutput)
620                    throws IOException, ServletException;
621    
622            public String renderPortlet(
623                            ServletContext servletContext, HttpServletRequest request,
624                            HttpServletResponse response, Portlet portlet, String queryString,
625                            String columnId, Integer columnPos, Integer columnCount,
626                            boolean writeOutput)
627                    throws IOException, ServletException;
628    
629            public String renderPortlet(
630                            ServletContext servletContext, HttpServletRequest request,
631                            HttpServletResponse response, Portlet portlet, String queryString,
632                            String columnId, Integer columnPos, Integer columnCount,
633                            String path, boolean writeOutput)
634                    throws IOException, ServletException;
635    
636            public void sendError(
637                            Exception e, ActionRequest actionRequest,
638                            ActionResponse actionResponse)
639                    throws IOException;
640    
641            public void sendError(
642                            Exception e, HttpServletRequest request,
643                            HttpServletResponse response)
644                    throws IOException, ServletException;
645    
646            public void sendError(
647                            int status, Exception e, ActionRequest actionRequest,
648                            ActionResponse actionResponse)
649                    throws IOException;
650    
651            public void sendError(
652                            int status, Exception e, HttpServletRequest request,
653                            HttpServletResponse response)
654                    throws IOException, ServletException;
655    
656            /**
657             * Sets the description for a page. This overrides the existing page
658             * description.
659             */
660            public void setPageDescription(
661                    String description, HttpServletRequest request);
662    
663            /**
664             * Sets the keywords for a page. This overrides the existing page keywords.
665             */
666            public void setPageKeywords(String keywords, HttpServletRequest request);
667    
668            /**
669             * Sets the subtitle for a page. This overrides the existing page subtitle.
670             */
671            public void setPageSubtitle(String subtitle, HttpServletRequest request);
672    
673            /**
674             * Sets the whole title for a page. This overrides the existing page whole
675             * title.
676             */
677            public void setPageTitle(String title, HttpServletRequest request);
678    
679            /**
680             * Sets the port obtained on the first request to the portal.
681             */
682            public void setPortalPort(HttpServletRequest request);
683    
684            public void storePreferences(PortletPreferences preferences)
685                    throws IOException, ValidatorException;
686    
687            public String transformCustomSQL(String sql);
688    
689            public PortletMode updatePortletMode(
690                    String portletId, User user, Layout layout, PortletMode portletMode,
691                    HttpServletRequest request);
692    
693            public WindowState updateWindowState(
694                    String portletId, User user, Layout layout, WindowState windowState,
695                    HttpServletRequest request);
696    
697    }