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  import com.liferay.portlet.expando.model.ExpandoBridge;
31  
32  import java.io.IOException;
33  import java.io.Serializable;
34  
35  import java.util.Date;
36  import java.util.List;
37  import java.util.Locale;
38  import java.util.Map;
39  import java.util.Properties;
40  import java.util.Set;
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  import javax.servlet.jsp.PageContext;
60  
61  /**
62   * <a href="Portal.java.html"><b><i>View Source</i></b></a>
63   *
64   * @author Brian Wing Shun Chan
65   * @author Eduardo Lundgren
66   */
67  public interface Portal {
68  
69      public static final String FRIENDLY_URL_SEPARATOR = "/-/";
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_CUSTOM =
78          "portlet-custom.xml";
79  
80      public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.xml";
81  
82      /**
83       * Adds the description for a page. This appends to the existing page
84       * description.
85       */
86      public void addPageDescription(
87          String description, HttpServletRequest request);
88  
89      /**
90       * Adds the keywords for a page. This appends to the existing page keywords.
91       */
92      public void addPageKeywords(String keywords, HttpServletRequest request);
93  
94      /**
95       * Adds the subtitle for a page. This appends to the existing page subtitle.
96       */
97      public void addPageSubtitle(String subtitle, HttpServletRequest request);
98  
99      /**
100      * Adds the whole title for a page. This appends to the existing page whole
101      * title.
102      */
103     public void addPageTitle(String title, HttpServletRequest request);
104 
105     public void clearRequestParameters(RenderRequest renderRequest);
106 
107     public void copyRequestParameters(
108         ActionRequest actionRequest, ActionResponse actionResponse);
109 
110     public String escapeRedirect(String url);
111 
112     public String generateRandomKey(HttpServletRequest request, String input);
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[] getCompanyIds();
166 
167     public String getComputerAddress();
168 
169     public String getComputerName();
170 
171     public String getControlPanelCategory(
172             String portletId, ThemeDisplay themeDisplay)
173         throws SystemException;
174 
175     public String getControlPanelFullURL(
176             long scopeGroupId, String ppid, Map<String, String[]> params)
177         throws PortalException, SystemException;
178 
179     public List<Portlet> getControlPanelPortlets(
180             String category, ThemeDisplay themeDisplay)
181         throws SystemException;
182 
183     public String getCurrentCompleteURL(HttpServletRequest request);
184 
185     public String getCurrentURL(HttpServletRequest request);
186 
187     public String getCurrentURL(PortletRequest portletRequest);
188 
189     public String getCustomSQLFunctionIsNotNull();
190 
191     public String getCustomSQLFunctionIsNull();
192 
193     public Date getDate(
194             int month, int day, int year, int hour, int min, PortalException pe)
195         throws PortalException;
196 
197     public Date getDate(
198             int month, int day, int year, int hour, int min, TimeZone timeZone,
199             PortalException pe)
200         throws PortalException;
201 
202     public Date getDate(int month, int day, int year, PortalException pe)
203         throws PortalException;
204 
205     public Date getDate(
206             int month, int day, int year, TimeZone timeZone, PortalException pe)
207         throws PortalException;
208 
209     public long getDefaultCompanyId();
210 
211     public Map<String, Serializable> getExpandoBridgeAttributes(
212             ExpandoBridge expandoBridge, PortletRequest portletRequest)
213         throws PortalException, SystemException;
214 
215     public String getFirstPageLayoutTypes(PageContext pageContext);
216 
217     public String getGlobalLibDir();
218 
219     public String getGoogleGadgetURL(
220         Portlet portlet, ThemeDisplay themeDisplay);
221 
222     public String[] getGuestPermissions(HttpServletRequest request);
223 
224     public String[] getGuestPermissions(PortletRequest portletRequest);
225 
226     public String getHomeURL(HttpServletRequest request)
227         throws PortalException, SystemException;
228 
229     public String getHost(HttpServletRequest request);
230 
231     public String getHost(PortletRequest portletRequest);
232 
233     public HttpServletRequest getHttpServletRequest(
234         PortletRequest portletRequest);
235 
236     public HttpServletResponse getHttpServletResponse(
237         PortletResponse portletResponse);
238 
239     public String getJsSafePortletId(String portletId) ;
240 
241     public String getLayoutActualURL(Layout layout);
242 
243     public String getLayoutActualURL(Layout layout, String mainPath);
244 
245     public String getLayoutActualURL(
246             long groupId, boolean privateLayout, String mainPath,
247             String friendlyURL)
248         throws PortalException, SystemException;
249 
250     public String getLayoutActualURL(
251             long groupId, boolean privateLayout, String mainPath,
252             String friendlyURL, Map<String, String[]> params)
253         throws PortalException, SystemException;
254 
255     public String getLayoutEditPage(Layout layout);
256 
257     public String getLayoutEditPage(String type);
258 
259     public String getLayoutFriendlyURL(
260         Layout layout, ThemeDisplay themeDisplay);
261 
262     public String getLayoutFriendlyURL(
263         Layout layout, ThemeDisplay themeDisplay, Locale locale);
264 
265     public String getLayoutFullURL(Layout layout, ThemeDisplay themeDisplay);
266 
267     public String getLayoutFullURL(
268         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser);
269 
270     public String getLayoutFullURL(long groupId, String portletId)
271         throws PortalException, SystemException;
272 
273     public String getLayoutFullURL(ThemeDisplay themeDisplay);
274 
275     public String getLayoutSetFriendlyURL(
276             LayoutSet layoutSet, ThemeDisplay themeDisplay)
277         throws PortalException, SystemException;
278 
279     public String getLayoutTarget(Layout layout);
280 
281     public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay);
282 
283     public String getLayoutURL(
284         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser);
285 
286     public String getLayoutURL(ThemeDisplay themeDisplay);
287 
288     public String getLayoutViewPage(Layout layout);
289 
290     public String getLayoutViewPage(String type);
291 
292     public Locale getLocale(HttpServletRequest request);
293 
294     public Locale getLocale(RenderRequest renderRequest);
295 
296     public String getNetvibesURL(Portlet portlet, ThemeDisplay themeDisplay);
297 
298     public HttpServletRequest getOriginalServletRequest(
299         HttpServletRequest request);
300 
301     public String getPathContext();
302 
303     public String getPathFriendlyURLPrivateGroup();
304 
305     public String getPathFriendlyURLPrivateUser();
306 
307     public String getPathFriendlyURLPublic();
308 
309     public String getPathImage();
310 
311     public String getPathMain();
312 
313     public long getPlidFromFriendlyURL(long companyId, String friendlyURL);
314 
315     public long getPlidFromPortletId(
316         long groupId, boolean privateLayout, String portletId);
317 
318     public long getPlidFromPortletId(long groupId, String portletId);
319 
320     public String getPortalLibDir();
321 
322     public int getPortalPort();
323 
324     public Properties getPortalProperties();
325 
326     public String getPortalURL(HttpServletRequest request);
327 
328     public String getPortalURL(HttpServletRequest request, boolean secure);
329 
330     public String getPortalURL(PortletRequest portletRequest);
331 
332     public String getPortalURL(PortletRequest portletRequest, boolean secure);
333 
334     public String getPortalURL(
335         String serverName, int serverPort, boolean secure);
336 
337     public String getPortalURL(ThemeDisplay themeDisplay);
338 
339     public String getPortalWebDir();
340 
341     public Set<String> getPortletAddDefaultResourceCheckWhitelist();
342 
343     public String getPortletDescription(
344         Portlet portlet, ServletContext servletContext, Locale locale);
345 
346     public String getPortletDescription(Portlet portlet, User user);
347 
348     public String getPortletDescription(String portletId, Locale locale);
349 
350     public String getPortletDescription(String portletId, String languageId);
351 
352     public String getPortletDescription(String portletId, User user);
353 
354     public Object[] getPortletFriendlyURLMapper(
355             long groupId, boolean privateLayout, String url)
356         throws PortalException, SystemException;
357 
358     public Object[] getPortletFriendlyURLMapper(
359             long groupId, boolean privateLayout, String url,
360             Map<String, String[]> params)
361         throws PortalException, SystemException;
362 
363     /**
364      * @deprecated Use <code>getScopeGroupId</code>.
365      */
366     public long getPortletGroupId(ActionRequest actionRequest);
367 
368     /**
369      * @deprecated Use <code>getScopeGroupId</code>.
370      */
371     public long getPortletGroupId(HttpServletRequest request);
372 
373     /**
374      * @deprecated Use <code>getScopeGroupId</code>.
375      */
376     public long getPortletGroupId(Layout layout);
377 
378     /**
379      * @deprecated Use <code>getScopeGroupId</code>.
380      */
381     public long getPortletGroupId(long plid);
382 
383     /**
384      * @deprecated Use <code>getScopeGroupId</code>.
385      */
386     public long getPortletGroupId(RenderRequest renderRequest);
387 
388     public String getPortletId(HttpServletRequest request);
389 
390     public String getPortletId(PortletRequest portletRequest);
391 
392     public String getPortletNamespace(String portletId);
393 
394     public String getPortletTitle(Portlet portlet, Locale locale);
395 
396     public String getPortletTitle(
397         Portlet portlet, ServletContext servletContext, Locale locale);
398 
399     public String getPortletTitle(Portlet portlet, String languageId);
400 
401     public String getPortletTitle(Portlet portlet, User user);
402 
403     public String getPortletTitle(String portletId, Locale locale);
404 
405     public String getPortletTitle(String portletId, String languageId);
406 
407     public String getPortletTitle(String portletId, User user);
408 
409     public String getPortletXmlFileName() throws SystemException;
410 
411     public PortletPreferences getPreferences(HttpServletRequest request);
412 
413     public PreferencesValidator getPreferencesValidator(
414         Portlet portlet);
415 
416     public long getScopeGroupId(HttpServletRequest request);
417 
418     public long getScopeGroupId(HttpServletRequest request, String portletId);
419 
420     public long getScopeGroupId(Layout layout);
421 
422     public long getScopeGroupId(Layout layout, String portletId);
423 
424     public long getScopeGroupId(long plid);
425 
426     public long getScopeGroupId(PortletRequest portletRequest);
427 
428     public User getSelectedUser(HttpServletRequest request)
429         throws PortalException, SystemException;
430 
431     public User getSelectedUser(
432             HttpServletRequest request, boolean checkPermission)
433         throws PortalException, SystemException;
434 
435     public User getSelectedUser(PortletRequest portletRequest)
436         throws PortalException, SystemException;
437 
438     public User getSelectedUser(
439             PortletRequest portletRequest, boolean checkPermission)
440         throws PortalException, SystemException;
441 
442     public ServletContext getServletContext(
443         Portlet portlet, ServletContext servletContext);
444 
445     public String getStaticResourceURL(
446         HttpServletRequest request, String uri);
447 
448     public String getStaticResourceURL(
449         HttpServletRequest request, String uri, long timestamp);
450 
451     public String getStaticResourceURL(
452         HttpServletRequest request, String uri, String queryString);
453 
454     public String getStaticResourceURL(
455         HttpServletRequest request, String uri, String queryString,
456         long timestamp);
457 
458     public String getStrutsAction(HttpServletRequest request);
459 
460     public String[] getSystemCommunityRoles();
461 
462     public String[] getSystemGroups();
463 
464     public String[] getSystemOrganizationRoles();
465 
466     public String[] getSystemRoles();
467 
468     public String[] getTagsCategories(PortletRequest portletRequest);
469 
470     public String[] getTagsEntries(PortletRequest portletRequest);
471 
472     public UploadPortletRequest getUploadPortletRequest(
473         PortletRequest portletRequest);
474 
475     public UploadServletRequest getUploadServletRequest(
476         HttpServletRequest request);
477 
478     public Date getUptime();
479 
480     public String getURLWithSessionId(String url, String sessionId);
481 
482     public User getUser(HttpServletRequest request)
483         throws PortalException, SystemException;
484 
485     public User getUser(PortletRequest portletRequest)
486         throws PortalException, SystemException;
487 
488     public long getUserId(HttpServletRequest request);
489 
490     public long getUserId(PortletRequest portletRequest);
491 
492     public String getUserName(long userId, String defaultUserName);
493 
494     public String getUserName(
495         long userId, String defaultUserName, HttpServletRequest request);
496 
497     public String getUserName(
498         long userId, String defaultUserName, String userAttribute);
499 
500     public String getUserName(
501         long userId, String defaultUserName, String userAttribute,
502         HttpServletRequest request);
503 
504     public String getUserPassword(HttpServletRequest request);
505 
506     public String getUserPassword(HttpSession session);
507 
508     public String getUserPassword(PortletRequest portletRequest);
509 
510     public String getUserValue(long userId, String param, String defaultValue)
511         throws SystemException;
512 
513     public long getValidUserId(long companyId, long userId)
514         throws PortalException, SystemException;
515 
516     public String getWidgetURL(Portlet portlet, ThemeDisplay themeDisplay);
517 
518     public boolean isLayoutFirstPageable(Layout layout);
519 
520     public boolean isLayoutFirstPageable(String type);
521 
522     public boolean isLayoutFriendliable(Layout layout);
523 
524     public boolean isLayoutFriendliable(String type);
525 
526     public boolean isLayoutParentable(Layout layout);
527 
528     public boolean isLayoutParentable(String type);
529 
530     public boolean isLayoutSitemapable(Layout layout);
531 
532     public boolean isMethodGet(PortletRequest portletRequest);
533 
534     public boolean isMethodPost(PortletRequest portletRequest);
535 
536     public boolean isReservedParameter(String name);
537 
538     public boolean isSystemGroup(String groupName);
539 
540     public boolean isSystemRole(String roleName);
541 
542     public boolean isUpdateAvailable() throws SystemException;
543 
544     public String renderPage(
545             ServletContext servletContext, HttpServletRequest request,
546             HttpServletResponse response, String path)
547         throws IOException, ServletException;
548 
549     public String renderPortlet(
550             ServletContext servletContext, HttpServletRequest request,
551             HttpServletResponse response, Portlet portlet, String queryString,
552             boolean writeOutput)
553         throws IOException, ServletException;
554 
555     public String renderPortlet(
556             ServletContext servletContext, HttpServletRequest request,
557             HttpServletResponse response, Portlet portlet, String queryString,
558             String columnId, Integer columnPos, Integer columnCount,
559             boolean writeOutput)
560         throws IOException, ServletException;
561 
562     public String renderPortlet(
563             ServletContext servletContext, HttpServletRequest request,
564             HttpServletResponse response, Portlet portlet, String queryString,
565             String columnId, Integer columnPos, Integer columnCount,
566             String path, boolean writeOutput)
567         throws IOException, ServletException;
568 
569     public void sendError(
570             Exception e, ActionRequest actionRequest,
571             ActionResponse actionResponse)
572         throws IOException;
573 
574     public void sendError(
575             Exception e, HttpServletRequest request,
576             HttpServletResponse response)
577         throws IOException, ServletException;
578 
579     public void sendError(
580             int status, Exception e, ActionRequest actionRequest,
581             ActionResponse actionResponse)
582         throws IOException;
583 
584     public void sendError(
585             int status, Exception e, HttpServletRequest request,
586             HttpServletResponse response)
587         throws IOException, ServletException;
588 
589     /**
590      * Sets the description for a page. This overrides the existing page
591      * description.
592      */
593     public void setPageDescription(
594         String description, HttpServletRequest request);
595 
596     /**
597      * Sets the keywords for a page. This overrides the existing page keywords.
598      */
599     public void setPageKeywords(String keywords, HttpServletRequest request);
600 
601     /**
602      * Sets the subtitle for a page. This overrides the existing page subtitle.
603      */
604     public void setPageSubtitle(String subtitle, HttpServletRequest request);
605 
606     /**
607      * Sets the whole title for a page. This overrides the existing page whole
608      * title.
609      */
610     public void setPageTitle(String title, HttpServletRequest request);
611 
612     /**
613      * Sets the port obtained on the first request to the portal.
614      */
615     public void setPortalPort(HttpServletRequest request);
616 
617     public void storePreferences(PortletPreferences preferences)
618         throws IOException, ValidatorException;
619 
620     public String transformCustomSQL(String sql);
621 
622     public PortletMode updatePortletMode(
623         String portletId, User user, Layout layout, PortletMode portletMode,
624         HttpServletRequest request);
625 
626     public WindowState updateWindowState(
627         String portletId, User user, Layout layout, WindowState windowState,
628         HttpServletRequest request);
629 
630 }