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