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.util.StringMaker;
28  import com.liferay.portal.model.Company;
29  import com.liferay.portal.model.Layout;
30  import com.liferay.portal.model.Portlet;
31  import com.liferay.portal.model.User;
32  import com.liferay.portal.theme.ThemeDisplay;
33  
34  import java.io.IOException;
35  
36  import java.rmi.RemoteException;
37  
38  import java.util.Date;
39  import java.util.Locale;
40  import java.util.Map;
41  import java.util.TimeZone;
42  
43  import javax.portlet.ActionRequest;
44  import javax.portlet.ActionResponse;
45  import javax.portlet.PortletMode;
46  import javax.portlet.PortletPreferences;
47  import javax.portlet.PortletRequest;
48  import javax.portlet.PortletResponse;
49  import javax.portlet.PreferencesValidator;
50  import javax.portlet.RenderRequest;
51  import javax.portlet.ValidatorException;
52  import javax.portlet.WindowState;
53  
54  import javax.servlet.ServletContext;
55  import javax.servlet.ServletException;
56  import javax.servlet.http.HttpServletRequest;
57  import javax.servlet.http.HttpServletResponse;
58  import javax.servlet.http.HttpSession;
59  
60  /**
61   * <a href="Portal.java.html"><b><i>View Source</i></b></a>
62   *
63   * @author Brian Wing Shun Chan
64   *
65   */
66  public interface Portal {
67  
68      public static final String PATH_IMAGE = "/image";
69  
70      public static final String PATH_MAIN = "/c";
71  
72      public static final String PATH_PORTAL_LAYOUT = "/portal/layout";
73  
74      public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.xml";
75  
76      public static final String PORTLET_XML_FILE_NAME_CUSTOM =
77          "portlet-custom.xml";
78  
79      public static final Date UP_TIME = new Date();
80  
81      public void clearRequestParameters(RenderRequest req);
82  
83      public void copyRequestParameters(ActionRequest req, ActionResponse res);
84  
85      public String getCDNHost();
86  
87      public String getClassName(long classNameId);
88  
89      public long getClassNameId(Class<?> classObj);
90  
91      public long getClassNameId(String value);
92  
93      public String getClassNamePortletId(String className);
94  
95      public Company getCompany(HttpServletRequest req)
96          throws PortalException, SystemException;
97  
98      public Company getCompany(ActionRequest req)
99          throws PortalException, SystemException;
100 
101     public Company getCompany(RenderRequest req)
102         throws PortalException, SystemException;
103 
104     public long getCompanyId(HttpServletRequest req);
105 
106     public long getCompanyId(ActionRequest req);
107 
108     public long getCompanyId(PortletRequest req);
109 
110     public long getCompanyId(RenderRequest req);
111 
112     public long getCompanyIdByWebId(ServletContext ctx);
113 
114     public long getCompanyIdByWebId(String webId);
115 
116     public String getComputerName();
117 
118     public String getCurrentURL(HttpServletRequest req);
119 
120     public String getCurrentURL(PortletRequest req);
121 
122     public Date getDate(int month, int day, int year, PortalException pe)
123         throws PortalException;
124 
125     public Date getDate(
126             int month, int day, int year, TimeZone timeZone, PortalException pe)
127         throws PortalException;
128 
129     public Date getDate(
130             int month, int day, int year, int hour, int min, PortalException pe)
131         throws PortalException;
132 
133     public Date getDate(
134             int month, int day, int year, int hour, int min, TimeZone timeZone,
135             PortalException pe)
136         throws PortalException;
137 
138     public String getHost(HttpServletRequest req);
139 
140     public String getHost(ActionRequest req);
141 
142     public String getHost(RenderRequest req);
143 
144     public HttpServletRequest getHttpServletRequest(PortletRequest req);
145 
146     public HttpServletResponse getHttpServletResponse(PortletResponse res);
147 
148     public String getLayoutEditPage(Layout layout);
149 
150     public String getLayoutViewPage(Layout layout);
151 
152     public String getLayoutURL(ThemeDisplay themeDisplay)
153         throws PortalException, SystemException;
154 
155     public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay)
156         throws PortalException, SystemException;
157 
158     public String getLayoutURL(
159             Layout layout, ThemeDisplay themeDisplay, boolean doAsUser)
160         throws PortalException, SystemException;
161 
162     public String getLayoutActualURL(Layout layout)
163         throws PortalException, SystemException;
164 
165     public String getLayoutActualURL(Layout layout, String mainPath)
166         throws PortalException, SystemException;
167 
168     public String getLayoutActualURL(
169             long groupId, boolean privateLayout, String mainPath,
170             String friendlyURL)
171         throws PortalException, SystemException;
172 
173     public String getLayoutActualURL(
174             long groupId, boolean privateLayout, String mainPath,
175             String friendlyURL, Map<String, String[]> params)
176         throws PortalException, SystemException;
177 
178     public String getLayoutFriendlyURL(Layout layout, ThemeDisplay themeDisplay)
179         throws PortalException, SystemException;
180 
181     public String getLayoutTarget(Layout layout);
182 
183     public String getJsSafePortletId(String portletId) ;
184 
185     public Locale getLocale(HttpServletRequest req);
186 
187     public Locale getLocale(RenderRequest req);
188 
189     public HttpServletRequest getOriginalServletRequest(
190         HttpServletRequest req);
191 
192     public String getPathContext();
193 
194     public String getPathFriendlyURLPrivateGroup();
195 
196     public String getPathFriendlyURLPrivateUser();
197 
198     public String getPathFriendlyURLPublic();
199 
200     public String getPathImage();
201 
202     public String getPathMain();
203 
204     public long getPlidIdFromFriendlyURL(long companyId, String friendlyURL);
205 
206     public String getPortalLibDir();
207 
208     public String getPortalURL(ThemeDisplay themeDisplay);
209 
210     public String getPortalURL(HttpServletRequest req);
211 
212     public String getPortalURL(HttpServletRequest req, boolean secure);
213 
214     public String getPortalURL(PortletRequest req);
215 
216     public String getPortalURL(PortletRequest req, boolean secure);
217 
218     public String getPortalURL(
219         String serverName, int serverPort, boolean secure);
220 
221     public Object[] getPortletFriendlyURLMapper(
222             long groupId, boolean privateLayout, String url)
223         throws PortalException, SystemException;
224 
225     public Object[] getPortletFriendlyURLMapper(
226             long groupId, boolean privateLayout, String url,
227             Map<String, String[]> params)
228         throws PortalException, SystemException;
229 
230     public long getPortletGroupId(long plid);
231 
232     public long getPortletGroupId(Layout layout);
233 
234     public long getPortletGroupId(HttpServletRequest req);
235 
236     public long getPortletGroupId(ActionRequest req);
237 
238     public long getPortletGroupId(RenderRequest req);
239 
240     public String getPortletNamespace(String portletId);
241 
242     public String getPortletTitle(
243         String portletId, long companyId, String languageId);
244 
245     public String getPortletTitle(
246         String portletId, long companyId, Locale locale);
247 
248     public String getPortletTitle(String portletId, User user);
249 
250     public String getPortletTitle(
251         Portlet portlet, ServletContext ctx, Locale locale);
252 
253     public String getPortletXmlFileName()
254         throws PortalException, SystemException;
255 
256     public PortletPreferences getPreferences(HttpServletRequest req);
257 
258     public PreferencesValidator getPreferencesValidator(
259         Portlet portlet);
260 
261     public User getSelectedUser(HttpServletRequest req)
262         throws PortalException, RemoteException, SystemException;
263 
264     public User getSelectedUser(HttpServletRequest req, boolean checkPermission)
265         throws PortalException, RemoteException, SystemException;
266 
267     public User getSelectedUser(ActionRequest req)
268         throws PortalException, RemoteException, SystemException;
269 
270     public User getSelectedUser(ActionRequest req, boolean checkPermission)
271         throws PortalException, RemoteException, SystemException;
272 
273     public User getSelectedUser(RenderRequest req)
274         throws PortalException, RemoteException, SystemException;
275 
276     public User getSelectedUser(RenderRequest req, boolean checkPermission)
277         throws PortalException, RemoteException, SystemException;
278 
279     public String getStrutsAction(HttpServletRequest req);
280 
281     public String[] getSystemCommunityRoles();
282 
283     public String[] getSystemGroups();
284 
285     public String[] getSystemOrganizationRoles();
286 
287     public String[] getSystemRoles();
288 
289     public Date getUptime();
290 
291     public String getURLWithSessionId(String url, String sessionId);
292 
293     public User getUser(HttpServletRequest req)
294         throws PortalException, SystemException;
295 
296     public User getUser(ActionRequest req)
297         throws PortalException, SystemException;
298 
299     public User getUser(RenderRequest req)
300         throws PortalException, SystemException;
301 
302     public long getUserId(HttpServletRequest req);
303 
304     public long getUserId(ActionRequest req);
305 
306     public long getUserId(RenderRequest req);
307 
308     public String getUserName(long userId, String defaultUserName);
309 
310     public String getUserName(
311         long userId, String defaultUserName, String userAttribute);
312 
313     public String getUserName(
314         long userId, String defaultUserName, HttpServletRequest req);
315 
316     public String getUserName(
317         long userId, String defaultUserName, String userAttribute,
318         HttpServletRequest req);
319 
320     public String getUserPassword(HttpSession ses);
321 
322     public String getUserPassword(HttpServletRequest req);
323 
324     public String getUserPassword(ActionRequest req);
325 
326     public String getUserPassword(RenderRequest req);
327 
328     public String getUserValue(long userId, String param, String defaultValue)
329         throws SystemException;
330 
331     public boolean isMethodGet(PortletRequest req);
332 
333     public boolean isMethodPost(PortletRequest req);
334 
335     public boolean isLayoutFriendliable(Layout layout);
336 
337     public boolean isLayoutParentable(Layout layout);
338 
339     public boolean isLayoutParentable(String type);
340 
341     public boolean isLayoutSitemapable(Layout layout);
342 
343     public boolean isReservedParameter(String name);
344 
345     public boolean isSystemGroup(String groupName);
346 
347     public boolean isSystemRole(String roleName);
348 
349     public boolean isUpdateAvailable() throws PortalException, SystemException;
350 
351     public void renderPage(
352             StringMaker sm, ServletContext ctx, HttpServletRequest req,
353             HttpServletResponse res, String path)
354         throws IOException, ServletException;
355 
356     public void renderPortlet(
357             StringMaker sm, ServletContext ctx, HttpServletRequest req,
358             HttpServletResponse res, Portlet portlet, String queryString)
359         throws IOException, ServletException;
360 
361     public void renderPortlet(
362             StringMaker sm, ServletContext ctx, HttpServletRequest req,
363             HttpServletResponse res, Portlet portlet, String queryString,
364             String columnId, Integer columnPos, Integer columnCount)
365         throws IOException, ServletException;
366 
367     public void renderPortlet(
368             StringMaker sm, ServletContext ctx, HttpServletRequest req,
369             HttpServletResponse res, Portlet portlet, String queryString,
370             String columnId, Integer columnPos, Integer columnCount,
371             String path)
372         throws IOException, ServletException;
373 
374     public void sendError(
375             int status, Exception e, HttpServletRequest req,
376             HttpServletResponse res)
377         throws IOException, ServletException;
378 
379     /**
380      * Sets the subtitle for a page. This is just a hint and can be overridden
381      * by subsequent calls. The last call to this method wins.
382      *
383      * @param       subtitle the subtitle for a page
384      * @param       req the HTTP servlet request
385      */
386     public void setPageSubtitle(String subtitle, HttpServletRequest req);
387 
388     /**
389      * Sets the whole title for a page. This is just a hint and can be
390      * overridden by subsequent calls. The last call to this method wins.
391      *
392      * @param       title the whole title for a page
393      * @param       req the HTTP servlet request
394      */
395     public void setPageTitle(String title, HttpServletRequest req);
396 
397     public void storePreferences(PortletPreferences prefs)
398         throws IOException, ValidatorException;
399 
400     public PortletMode updatePortletMode(
401             String portletId, User user, Layout layout, PortletMode portletMode,
402             HttpServletRequest req)
403         throws PortalException, RemoteException, SystemException;
404 
405     public WindowState updateWindowState(
406             String portletId, User user, Layout layout, WindowState windowState,
407             HttpServletRequest req)
408         throws PortalException, RemoteException, SystemException;
409 
410 }