1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.util;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.upload.UploadPortletRequest;
28  import com.liferay.portal.kernel.upload.UploadServletRequest;
29  import com.liferay.portal.model.BaseModel;
30  import com.liferay.portal.model.Company;
31  import com.liferay.portal.model.Layout;
32  import com.liferay.portal.model.LayoutSet;
33  import com.liferay.portal.model.Portlet;
34  import com.liferay.portal.model.Resource;
35  import com.liferay.portal.model.ResourcePermission;
36  import com.liferay.portal.model.User;
37  import com.liferay.portal.theme.ThemeDisplay;
38  import com.liferay.portlet.expando.model.ExpandoBridge;
39  
40  import java.io.IOException;
41  import java.io.Serializable;
42  
43  import java.util.Date;
44  import java.util.List;
45  import java.util.Locale;
46  import java.util.Map;
47  import java.util.Properties;
48  import java.util.TimeZone;
49  
50  import javax.portlet.ActionRequest;
51  import javax.portlet.ActionResponse;
52  import javax.portlet.PortletMode;
53  import javax.portlet.PortletPreferences;
54  import javax.portlet.PortletRequest;
55  import javax.portlet.PortletResponse;
56  import javax.portlet.PreferencesValidator;
57  import javax.portlet.RenderRequest;
58  import javax.portlet.ValidatorException;
59  import javax.portlet.WindowState;
60  
61  import javax.servlet.ServletContext;
62  import javax.servlet.ServletException;
63  import javax.servlet.http.HttpServletRequest;
64  import javax.servlet.http.HttpServletResponse;
65  import javax.servlet.http.HttpSession;
66  import javax.servlet.jsp.PageContext;
67  
68  /**
69   * <a href="Portal.java.html"><b><i>View Source</i></b></a>
70   *
71   * @author Brian Wing Shun Chan
72   * @author Eduardo Lundgren
73   */
74  public interface Portal {
75  
76      public static final String FRIENDLY_URL_SEPARATOR = "/-/";
77  
78      public static final String PATH_IMAGE = "/image";
79  
80      public static final String PATH_MAIN = "/c";
81  
82      public static final String PATH_PORTAL_LAYOUT = "/portal/layout";
83  
84      public static final String PORTLET_XML_FILE_NAME_CUSTOM =
85          "portlet-custom.xml";
86  
87      public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.xml";
88  
89      /**
90       * Adds the description for a page. This appends to the existing page
91       * description.
92       */
93      public void addPageDescription(
94          String description, HttpServletRequest request);
95  
96      /**
97       * Adds the keywords for a page. This appends to the existing page keywords.
98       */
99      public void addPageKeywords(String keywords, HttpServletRequest request);
100 
101     /**
102      * Adds the subtitle for a page. This appends to the existing page subtitle.
103      */
104     public void addPageSubtitle(String subtitle, HttpServletRequest request);
105 
106     /**
107      * Adds the whole title for a page. This appends to the existing page whole
108      * title.
109      */
110     public void addPageTitle(String title, HttpServletRequest request);
111 
112     public void clearRequestParameters(RenderRequest renderRequest);
113 
114     public void copyRequestParameters(
115         ActionRequest actionRequest, ActionResponse actionResponse);
116 
117     public String escapeRedirect(String url);
118 
119     public long getBasicAuthUserId(HttpServletRequest request)
120         throws PortalException, SystemException;
121 
122     public long getBasicAuthUserId(HttpServletRequest request, long companyId)
123         throws PortalException, SystemException;
124 
125     /**
126      * @deprecated {@link #getCDNHost(boolean)}
127      */
128     public String getCDNHost();
129 
130     public String getCDNHost(boolean secure);
131 
132     public String getCDNHostHttp();
133 
134     public String getCDNHostHttps();
135 
136     public String getClassName(long classNameId);
137 
138     public long getClassNameId(Class<?> classObj);
139 
140     public long getClassNameId(String value);
141 
142     public String getClassNamePortletId(String className);
143 
144     public String getCommunityLoginURL(ThemeDisplay themeDisplay)
145         throws PortalException, SystemException;
146 
147     public String[] getCommunityPermissions(HttpServletRequest request);
148 
149     public String[] getCommunityPermissions(PortletRequest portletRequest);
150 
151     public Company getCompany(HttpServletRequest request)
152         throws PortalException, SystemException;
153 
154     public Company getCompany(PortletRequest portletRequest)
155         throws PortalException, SystemException;
156 
157     public long getCompanyId(HttpServletRequest requestuest);
158 
159     public long getCompanyId(PortletRequest portletRequest);
160 
161     public long[] getCompanyIds();
162 
163     public String getComputerAddress();
164 
165     public String getComputerName();
166 
167     public String getControlPanelCategory(
168             String portletId, ThemeDisplay themeDisplay)
169         throws SystemException;
170 
171     public List<Portlet> getControlPanelPortlets(
172             String category, ThemeDisplay themeDisplay)
173         throws SystemException;
174 
175     public String getCurrentCompleteURL(HttpServletRequest request);
176 
177     public String getCurrentURL(HttpServletRequest request);
178 
179     public String getCurrentURL(PortletRequest portletRequest);
180 
181     public String getCustomSQLFunctionIsNotNull();
182 
183     public String getCustomSQLFunctionIsNull();
184 
185     public Date getDate(
186             int month, int day, int year, int hour, int min, PortalException pe)
187         throws PortalException;
188 
189     public Date getDate(
190             int month, int day, int year, int hour, int min, TimeZone timeZone,
191             PortalException pe)
192         throws PortalException;
193 
194     public Date getDate(int month, int day, int year, PortalException pe)
195         throws PortalException;
196 
197     public Date getDate(
198             int month, int day, int year, TimeZone timeZone, PortalException pe)
199         throws PortalException;
200 
201     public long getDefaultCompanyId();
202 
203     public Map<String, Serializable> getExpandoBridgeAttributes(
204             ExpandoBridge expandoBridge, PortletRequest portletRequest)
205         throws PortalException, SystemException;
206 
207     public String getFirstPageLayoutTypes(PageContext pageContext);
208 
209     public String getGoogleGadgetURL(
210         Portlet portlet, ThemeDisplay themeDisplay);
211 
212     public String[] getGuestPermissions(HttpServletRequest request);
213 
214     public String[] getGuestPermissions(PortletRequest portletRequest);
215 
216     public String getHomeURL(HttpServletRequest request)
217         throws PortalException, SystemException;
218 
219     public String getHost(HttpServletRequest request);
220 
221     public String getHost(PortletRequest portletRequest);
222 
223     public HttpServletRequest getHttpServletRequest(
224         PortletRequest portletRequest);
225 
226     public HttpServletResponse getHttpServletResponse(
227         PortletResponse portletResponse);
228 
229     public String getJsSafePortletId(String portletId) ;
230 
231     public String getLayoutActualURL(Layout layout);
232 
233     public String getLayoutActualURL(Layout layout, String mainPath);
234 
235     public String getLayoutActualURL(
236             long groupId, boolean privateLayout, String mainPath,
237             String friendlyURL)
238         throws PortalException, SystemException;
239 
240     public String getLayoutActualURL(
241             long groupId, boolean privateLayout, String mainPath,
242             String friendlyURL, Map<String, String[]> params)
243         throws PortalException, SystemException;
244 
245     public String getLayoutEditPage(Layout layout);
246 
247     public String getLayoutFriendlyURL(
248         Layout layout, ThemeDisplay themeDisplay);
249 
250     public String getLayoutFriendlyURL(
251         Layout layout, ThemeDisplay themeDisplay, Locale locale);
252 
253     public String getLayoutFullURL(Layout layout, ThemeDisplay themeDisplay);
254 
255     public String getLayoutFullURL(
256         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser);
257 
258     public String getLayoutFullURL(ThemeDisplay themeDisplay);
259 
260     public String getLayoutSetFriendlyURL(
261             LayoutSet layoutSet, ThemeDisplay themeDisplay)
262         throws PortalException, SystemException;
263 
264     public String getLayoutTarget(Layout layout);
265 
266     public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay);
267 
268     public String getLayoutURL(
269         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser);
270 
271     public String getLayoutURL(ThemeDisplay themeDisplay);
272 
273     public String getLayoutViewPage(Layout layout);
274 
275     public Locale getLocale(HttpServletRequest request);
276 
277     public Locale getLocale(RenderRequest renderRequest);
278 
279     public BaseModel<?> getModel(Resource resource)
280         throws PortalException, SystemException;
281 
282     public BaseModel<?> getModel(ResourcePermission resourcePermission)
283         throws PortalException, SystemException;
284 
285     public BaseModel<?> getModel(String modelName, String primKey)
286         throws PortalException, SystemException;
287 
288     public String getNetvibesURL(Portlet portlet, ThemeDisplay themeDisplay);
289 
290     public HttpServletRequest getOriginalServletRequest(
291         HttpServletRequest request);
292 
293     public String getPathContext();
294 
295     public String getPathFriendlyURLPrivateGroup();
296 
297     public String getPathFriendlyURLPrivateUser();
298 
299     public String getPathFriendlyURLPublic();
300 
301     public String getPathImage();
302 
303     public String getPathMain();
304 
305     public long getPlidFromFriendlyURL(long companyId, String friendlyURL);
306 
307     public long getPlidFromPortletId(
308         long groupId, boolean privateLayout, String portletId);
309 
310     public long getPlidFromPortletId(long groupId, String portletId);
311 
312     public String getPortalLibDir();
313 
314     public int getPortalPort();
315 
316     public Properties getPortalProperties();
317 
318     public String getPortalURL(HttpServletRequest request);
319 
320     public String getPortalURL(HttpServletRequest request, boolean secure);
321 
322     public String getPortalURL(PortletRequest portletRequest);
323 
324     public String getPortalURL(PortletRequest portletRequest, boolean secure);
325 
326     public String getPortalURL(
327         String serverName, int serverPort, boolean secure);
328 
329     public String getPortalURL(ThemeDisplay themeDisplay);
330 
331     public String getPortalWebDir();
332 
333     public String getPortletDescription(
334         Portlet portlet, ServletContext servletContext, Locale locale);
335 
336     public String getPortletDescription(Portlet portlet, User user);
337 
338     public String getPortletDescription(String portletId, Locale locale);
339 
340     public String getPortletDescription(String portletId, String languageId);
341 
342     public String getPortletDescription(String portletId, User user);
343 
344     public Object[] getPortletFriendlyURLMapper(
345             long groupId, boolean privateLayout, String url)
346         throws PortalException, SystemException;
347 
348     public Object[] getPortletFriendlyURLMapper(
349             long groupId, boolean privateLayout, String url,
350             Map<String, String[]> params)
351         throws PortalException, SystemException;
352 
353     /**
354      * @deprecated Use <code>getScopeGroupId</code>.
355      */
356     public long getPortletGroupId(ActionRequest actionRequest);
357 
358     /**
359      * @deprecated Use <code>getScopeGroupId</code>.
360      */
361     public long getPortletGroupId(HttpServletRequest request);
362 
363     /**
364      * @deprecated Use <code>getScopeGroupId</code>.
365      */
366     public long getPortletGroupId(Layout layout);
367 
368     /**
369      * @deprecated Use <code>getScopeGroupId</code>.
370      */
371     public long getPortletGroupId(long plid);
372 
373     /**
374      * @deprecated Use <code>getScopeGroupId</code>.
375      */
376     public long getPortletGroupId(RenderRequest renderRequest);
377 
378     public String getPortletId(HttpServletRequest request);
379 
380     public String getPortletId(PortletRequest portletRequest);
381 
382     public String getPortletNamespace(String portletId);
383 
384     public String getPortletTitle(Portlet portlet, Locale locale);
385 
386     public String getPortletTitle(Portlet portlet, String languageId);
387 
388     public String getPortletTitle(
389         Portlet portlet, ServletContext servletContext, Locale locale);
390 
391     public String getPortletTitle(Portlet portlet, User user);
392 
393     public String getPortletTitle(String portletId, Locale locale);
394 
395     public String getPortletTitle(String portletId, String languageId);
396 
397     public String getPortletTitle(String portletId, User user);
398 
399     public String getPortletXmlFileName() throws SystemException;
400 
401     public PortletPreferences getPreferences(HttpServletRequest request);
402 
403     public PreferencesValidator getPreferencesValidator(
404         Portlet portlet);
405 
406     public long getScopeGroupId(HttpServletRequest request);
407 
408     public long getScopeGroupId(HttpServletRequest request, String portletId);
409 
410     public long getScopeGroupId(Layout layout);
411 
412     public long getScopeGroupId(Layout layout, String portletId);
413 
414     public long getScopeGroupId(long plid);
415 
416     public long getScopeGroupId(PortletRequest portletRequest);
417 
418     public User getSelectedUser(HttpServletRequest request)
419         throws PortalException, SystemException;
420 
421     public User getSelectedUser(
422             HttpServletRequest request, boolean checkPermission)
423         throws PortalException, SystemException;
424 
425     public User getSelectedUser(PortletRequest portletRequest)
426         throws PortalException, SystemException;
427 
428     public User getSelectedUser(
429             PortletRequest portletRequest, boolean checkPermission)
430         throws PortalException, SystemException;
431 
432     public String getStaticResourceURL(
433         HttpServletRequest request, String uri);
434 
435     public String getStaticResourceURL(
436         HttpServletRequest request, String uri, long timestamp);
437 
438     public String getStaticResourceURL(
439         HttpServletRequest request, String uri, String queryString);
440 
441     public String getStaticResourceURL(
442         HttpServletRequest request, String uri, String queryString,
443         long timestamp);
444 
445     public String getStrutsAction(HttpServletRequest request);
446 
447     public String[] getSystemCommunityRoles();
448 
449     public String[] getSystemGroups();
450 
451     public String[] getSystemOrganizationRoles();
452 
453     public String[] getSystemRoles();
454 
455     public String[] getTagsCategories(PortletRequest portletRequest);
456 
457     public String[] getTagsEntries(PortletRequest portletRequest);
458 
459     public UploadPortletRequest getUploadPortletRequest(
460         ActionRequest actionRequest);
461 
462     public UploadServletRequest getUploadServletRequest(
463         HttpServletRequest request);
464 
465     public Date getUptime();
466 
467     public String getURLWithSessionId(String url, String sessionId);
468 
469     public User getUser(HttpServletRequest request)
470         throws PortalException, SystemException;
471 
472     public User getUser(PortletRequest portletRequest)
473         throws PortalException, SystemException;
474 
475     public long getUserId(HttpServletRequest request);
476 
477     public long getUserId(PortletRequest portletRequest);
478 
479     public String getUserName(long userId, String defaultUserName);
480 
481     public String getUserName(
482         long userId, String defaultUserName, HttpServletRequest request);
483 
484     public String getUserName(
485         long userId, String defaultUserName, String userAttribute);
486 
487     public String getUserName(
488         long userId, String defaultUserName, String userAttribute,
489         HttpServletRequest request);
490 
491     public String getUserPassword(HttpServletRequest request);
492 
493     public String getUserPassword(HttpSession session);
494 
495     public String getUserPassword(PortletRequest portletRequest);
496 
497     public String getUserValue(long userId, String param, String defaultValue)
498         throws SystemException;
499 
500     public String getWidgetURL(Portlet portlet, ThemeDisplay themeDisplay);
501 
502     public boolean isLayoutFirstPageable(String type);
503 
504     public boolean isLayoutFriendliable(Layout layout);
505 
506     public boolean isLayoutParentable(Layout layout);
507 
508     public boolean isLayoutParentable(String type);
509 
510     public boolean isLayoutSitemapable(Layout layout);
511 
512     public boolean isMethodGet(PortletRequest portletRequest);
513 
514     public boolean isMethodPost(PortletRequest portletRequest);
515 
516     public boolean isReservedParameter(String name);
517 
518     public boolean isSystemGroup(String groupName);
519 
520     public boolean isSystemRole(String roleName);
521 
522     public boolean isUpdateAvailable() throws SystemException;
523 
524     public void renderPage(
525             StringBuilder sb, ServletContext servletContext,
526             HttpServletRequest request, HttpServletResponse response,
527             String path)
528         throws IOException, ServletException;
529 
530     public void renderPortlet(
531             StringBuilder sb, ServletContext servletContext,
532             HttpServletRequest request, HttpServletResponse response,
533             Portlet portlet, String queryString)
534         throws IOException, ServletException;
535 
536     public void renderPortlet(
537             StringBuilder sb, ServletContext servletContext,
538             HttpServletRequest request, HttpServletResponse response,
539             Portlet portlet, String queryString, String columnId,
540             Integer columnPos, Integer columnCount)
541         throws IOException, ServletException;
542 
543     public void renderPortlet(
544             StringBuilder sb, ServletContext servletContext,
545             HttpServletRequest request, HttpServletResponse response,
546             Portlet portlet, String queryString, String columnId,
547             Integer columnPos, Integer columnCount, String path)
548         throws IOException, ServletException;
549 
550     public void sendError(
551             Exception e, ActionRequest actionRequest,
552             ActionResponse actionResponse)
553         throws IOException;
554 
555     public void sendError(
556             Exception e, HttpServletRequest request,
557             HttpServletResponse response)
558         throws IOException, ServletException;
559 
560     public void sendError(
561             int status, Exception e, ActionRequest actionRequest,
562             ActionResponse actionResponse)
563         throws IOException;
564 
565     public void sendError(
566             int status, Exception e, HttpServletRequest request,
567             HttpServletResponse response)
568         throws IOException, ServletException;
569 
570     /**
571      * Sets the description for a page. This overrides the existing page
572      * description.
573      */
574     public void setPageDescription(
575         String description, HttpServletRequest request);
576 
577     /**
578      * Sets the keywords for a page. This overrides the existing page keywords.
579      */
580     public void setPageKeywords(String keywords, HttpServletRequest request);
581 
582     /**
583      * Sets the subtitle for a page. This overrides the existing page subtitle.
584      */
585     public void setPageSubtitle(String subtitle, HttpServletRequest request);
586 
587     /**
588      * Sets the whole title for a page. This overrides the existing page whole
589      * title.
590      */
591     public void setPageTitle(String title, HttpServletRequest request);
592 
593     /**
594      * Sets the port obtained on the first request to the portal.
595      */
596     public void setPortalPort(HttpServletRequest request);
597 
598     public void storePreferences(PortletPreferences preferences)
599         throws IOException, ValidatorException;
600 
601     public String transformCustomSQL(String sql);
602 
603     public PortletMode updatePortletMode(
604         String portletId, User user, Layout layout, PortletMode portletMode,
605         HttpServletRequest request);
606 
607     public WindowState updateWindowState(
608         String portletId, User user, Layout layout, WindowState windowState,
609         HttpServletRequest request);
610 
611 }