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