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