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