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