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