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