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