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