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