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