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.service.persistence.BasePersistence;
38  import com.liferay.portal.theme.ThemeDisplay;
39  import com.liferay.portlet.expando.model.ExpandoBridge;
40  
41  import java.io.IOException;
42  import java.io.Serializable;
43  
44  import java.util.Date;
45  import java.util.List;
46  import java.util.Locale;
47  import java.util.Map;
48  import java.util.Properties;
49  import java.util.TimeZone;
50  
51  import javax.portlet.ActionRequest;
52  import javax.portlet.ActionResponse;
53  import javax.portlet.PortletMode;
54  import javax.portlet.PortletPreferences;
55  import javax.portlet.PortletRequest;
56  import javax.portlet.PortletResponse;
57  import javax.portlet.PreferencesValidator;
58  import javax.portlet.RenderRequest;
59  import javax.portlet.ValidatorException;
60  import javax.portlet.WindowState;
61  
62  import javax.servlet.ServletContext;
63  import javax.servlet.ServletException;
64  import javax.servlet.http.HttpServletRequest;
65  import javax.servlet.http.HttpServletResponse;
66  import javax.servlet.http.HttpSession;
67  import javax.servlet.jsp.PageContext;
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_CUSTOM =
86          "portlet-custom.xml";
87  
88      public static final String PORTLET_XML_FILE_NAME_STANDARD = "portlet.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     public String escapeRedirect(String url);
119 
120     public BaseModel<?> getBaseModel(Resource resource)
121         throws PortalException, SystemException;
122 
123     public BaseModel<?> getBaseModel(ResourcePermission resourcePermission)
124         throws PortalException, SystemException;
125 
126     public BaseModel<?> getBaseModel(String modelName, String primKey)
127         throws PortalException, SystemException;
128 
129     public BasePersistence<?> getBasePersistence(BaseModel<?> baseModel);
130 
131     public BasePersistence<?> getBasePersistence(
132         String servletContextName, String className);
133 
134     public long getBasicAuthUserId(HttpServletRequest request)
135         throws PortalException, SystemException;
136 
137     public long getBasicAuthUserId(HttpServletRequest request, long companyId)
138         throws PortalException, SystemException;
139 
140     /**
141      * @deprecated {@link #getCDNHost(boolean)}
142      */
143     public String getCDNHost();
144 
145     public String getCDNHost(boolean secure);
146 
147     public String getCDNHostHttp();
148 
149     public String getCDNHostHttps();
150 
151     public String getClassName(long classNameId);
152 
153     public long getClassNameId(Class<?> classObj);
154 
155     public long getClassNameId(String value);
156 
157     public String getClassNamePortletId(String className);
158 
159     public String getCommunityLoginURL(ThemeDisplay themeDisplay)
160         throws PortalException, SystemException;
161 
162     public String[] getCommunityPermissions(HttpServletRequest request);
163 
164     public String[] getCommunityPermissions(PortletRequest portletRequest);
165 
166     public Company getCompany(HttpServletRequest request)
167         throws PortalException, SystemException;
168 
169     public Company getCompany(PortletRequest portletRequest)
170         throws PortalException, SystemException;
171 
172     public long getCompanyId(HttpServletRequest requestuest);
173 
174     public long getCompanyId(PortletRequest portletRequest);
175 
176     public long[] getCompanyIds();
177 
178     public String getComputerAddress();
179 
180     public String getComputerName();
181 
182     public String getControlPanelCategory(
183             String portletId, ThemeDisplay themeDisplay)
184         throws SystemException;
185 
186     public List<Portlet> getControlPanelPortlets(
187             String category, ThemeDisplay themeDisplay)
188         throws SystemException;
189 
190     public String getCurrentCompleteURL(HttpServletRequest request);
191 
192     public String getCurrentURL(HttpServletRequest request);
193 
194     public String getCurrentURL(PortletRequest portletRequest);
195 
196     public String getCustomSQLFunctionIsNotNull();
197 
198     public String getCustomSQLFunctionIsNull();
199 
200     public Date getDate(
201             int month, int day, int year, int hour, int min, PortalException pe)
202         throws PortalException;
203 
204     public Date getDate(
205             int month, int day, int year, int hour, int min, TimeZone timeZone,
206             PortalException pe)
207         throws PortalException;
208 
209     public Date getDate(int month, int day, int year, PortalException pe)
210         throws PortalException;
211 
212     public Date getDate(
213             int month, int day, int year, TimeZone timeZone, PortalException pe)
214         throws PortalException;
215 
216     public long getDefaultCompanyId();
217 
218     public Map<String, Serializable> getExpandoBridgeAttributes(
219             ExpandoBridge expandoBridge, PortletRequest portletRequest)
220         throws PortalException, SystemException;
221 
222     public String getFirstPageLayoutTypes(PageContext pageContext);
223 
224     public String getGlobalLibDir();
225 
226     public String getGoogleGadgetURL(
227         Portlet portlet, ThemeDisplay themeDisplay);
228 
229     public String[] getGuestPermissions(HttpServletRequest request);
230 
231     public String[] getGuestPermissions(PortletRequest portletRequest);
232 
233     public String getHomeURL(HttpServletRequest request)
234         throws PortalException, SystemException;
235 
236     public String getHost(HttpServletRequest request);
237 
238     public String getHost(PortletRequest portletRequest);
239 
240     public HttpServletRequest getHttpServletRequest(
241         PortletRequest portletRequest);
242 
243     public HttpServletResponse getHttpServletResponse(
244         PortletResponse portletResponse);
245 
246     public String getJsSafePortletId(String portletId) ;
247 
248     public String getLayoutActualURL(Layout layout);
249 
250     public String getLayoutActualURL(Layout layout, String mainPath);
251 
252     public String getLayoutActualURL(
253             long groupId, boolean privateLayout, String mainPath,
254             String friendlyURL)
255         throws PortalException, SystemException;
256 
257     public String getLayoutActualURL(
258             long groupId, boolean privateLayout, String mainPath,
259             String friendlyURL, Map<String, String[]> params)
260         throws PortalException, SystemException;
261 
262     public String getLayoutEditPage(Layout layout);
263 
264     public String getLayoutFriendlyURL(
265         Layout layout, ThemeDisplay themeDisplay);
266 
267     public String getLayoutFriendlyURL(
268         Layout layout, ThemeDisplay themeDisplay, Locale locale);
269 
270     public String getLayoutFullURL(Layout layout, ThemeDisplay themeDisplay);
271 
272     public String getLayoutFullURL(
273         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser);
274 
275     public String getLayoutFullURL(long groupId, String portletId)
276         throws PortalException, SystemException;
277 
278     public String getLayoutFullURL(ThemeDisplay themeDisplay);
279 
280     public String getLayoutSetFriendlyURL(
281             LayoutSet layoutSet, ThemeDisplay themeDisplay)
282         throws PortalException, SystemException;
283 
284     public String getLayoutTarget(Layout layout);
285 
286     public String getLayoutURL(Layout layout, ThemeDisplay themeDisplay);
287 
288     public String getLayoutURL(
289         Layout layout, ThemeDisplay themeDisplay, boolean doAsUser);
290 
291     public String getLayoutURL(ThemeDisplay themeDisplay);
292 
293     public String getLayoutViewPage(Layout layout);
294 
295     public Locale getLocale(HttpServletRequest request);
296 
297     public Locale getLocale(RenderRequest renderRequest);
298 
299     public String getNetvibesURL(Portlet portlet, ThemeDisplay themeDisplay);
300 
301     public HttpServletRequest getOriginalServletRequest(
302         HttpServletRequest request);
303 
304     public String getPathContext();
305 
306     public String getPathFriendlyURLPrivateGroup();
307 
308     public String getPathFriendlyURLPrivateUser();
309 
310     public String getPathFriendlyURLPublic();
311 
312     public String getPathImage();
313 
314     public String getPathMain();
315 
316     public long getPlidFromFriendlyURL(long companyId, String friendlyURL);
317 
318     public long getPlidFromPortletId(
319         long groupId, boolean privateLayout, String portletId);
320 
321     public long getPlidFromPortletId(long groupId, String portletId);
322 
323     public String getPortalLibDir();
324 
325     public int getPortalPort();
326 
327     public Properties getPortalProperties();
328 
329     public String getPortalURL(HttpServletRequest request);
330 
331     public String getPortalURL(HttpServletRequest request, boolean secure);
332 
333     public String getPortalURL(PortletRequest portletRequest);
334 
335     public String getPortalURL(PortletRequest portletRequest, boolean secure);
336 
337     public String getPortalURL(
338         String serverName, int serverPort, boolean secure);
339 
340     public String getPortalURL(ThemeDisplay themeDisplay);
341 
342     public String getPortalWebDir();
343 
344     public String getPortletDescription(
345         Portlet portlet, ServletContext servletContext, Locale locale);
346 
347     public String getPortletDescription(Portlet portlet, User user);
348 
349     public String getPortletDescription(String portletId, Locale locale);
350 
351     public String getPortletDescription(String portletId, String languageId);
352 
353     public String getPortletDescription(String portletId, User user);
354 
355     public Object[] getPortletFriendlyURLMapper(
356             long groupId, boolean privateLayout, String url)
357         throws PortalException, SystemException;
358 
359     public Object[] getPortletFriendlyURLMapper(
360             long groupId, boolean privateLayout, String url,
361             Map<String, String[]> params)
362         throws PortalException, SystemException;
363 
364     /**
365      * @deprecated Use <code>getScopeGroupId</code>.
366      */
367     public long getPortletGroupId(ActionRequest actionRequest);
368 
369     /**
370      * @deprecated Use <code>getScopeGroupId</code>.
371      */
372     public long getPortletGroupId(HttpServletRequest request);
373 
374     /**
375      * @deprecated Use <code>getScopeGroupId</code>.
376      */
377     public long getPortletGroupId(Layout layout);
378 
379     /**
380      * @deprecated Use <code>getScopeGroupId</code>.
381      */
382     public long getPortletGroupId(long plid);
383 
384     /**
385      * @deprecated Use <code>getScopeGroupId</code>.
386      */
387     public long getPortletGroupId(RenderRequest renderRequest);
388 
389     public String getPortletId(HttpServletRequest request);
390 
391     public String getPortletId(PortletRequest portletRequest);
392 
393     public String getPortletNamespace(String portletId);
394 
395     public String getPortletTitle(Portlet portlet, Locale locale);
396 
397     public String getPortletTitle(
398         Portlet portlet, ServletContext servletContext, Locale locale);
399 
400     public String getPortletTitle(Portlet portlet, String languageId);
401 
402     public String getPortletTitle(Portlet portlet, User user);
403 
404     public String getPortletTitle(String portletId, Locale locale);
405 
406     public String getPortletTitle(String portletId, String languageId);
407 
408     public String getPortletTitle(String portletId, User user);
409 
410     public String getPortletXmlFileName() throws SystemException;
411 
412     public PortletPreferences getPreferences(HttpServletRequest request);
413 
414     public PreferencesValidator getPreferencesValidator(
415         Portlet portlet);
416 
417     public long getScopeGroupId(HttpServletRequest request);
418 
419     public long getScopeGroupId(HttpServletRequest request, String portletId);
420 
421     public long getScopeGroupId(Layout layout);
422 
423     public long getScopeGroupId(Layout layout, String portletId);
424 
425     public long getScopeGroupId(long plid);
426 
427     public long getScopeGroupId(PortletRequest portletRequest);
428 
429     public User getSelectedUser(HttpServletRequest request)
430         throws PortalException, SystemException;
431 
432     public User getSelectedUser(
433             HttpServletRequest request, boolean checkPermission)
434         throws PortalException, SystemException;
435 
436     public User getSelectedUser(PortletRequest portletRequest)
437         throws PortalException, SystemException;
438 
439     public User getSelectedUser(
440             PortletRequest portletRequest, boolean checkPermission)
441         throws PortalException, SystemException;
442 
443     public String getServletContextName(BaseModel<?> baseModel);
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         ActionRequest actionRequest);
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 String getWidgetURL(Portlet portlet, ThemeDisplay themeDisplay);
514 
515     public boolean isLayoutFirstPageable(String type);
516 
517     public boolean isLayoutFriendliable(Layout layout);
518 
519     public boolean isLayoutParentable(Layout layout);
520 
521     public boolean isLayoutParentable(String type);
522 
523     public boolean isLayoutSitemapable(Layout layout);
524 
525     public boolean isMethodGet(PortletRequest portletRequest);
526 
527     public boolean isMethodPost(PortletRequest portletRequest);
528 
529     public boolean isReservedParameter(String name);
530 
531     public boolean isSystemGroup(String groupName);
532 
533     public boolean isSystemRole(String roleName);
534 
535     public boolean isUpdateAvailable() throws SystemException;
536 
537     public void renderPage(
538             StringBuilder sb, ServletContext servletContext,
539             HttpServletRequest request, HttpServletResponse response,
540             String path)
541         throws IOException, ServletException;
542 
543     public void renderPortlet(
544             StringBuilder sb, ServletContext servletContext,
545             HttpServletRequest request, HttpServletResponse response,
546             Portlet portlet, String queryString)
547         throws IOException, ServletException;
548 
549     public void renderPortlet(
550             StringBuilder sb, ServletContext servletContext,
551             HttpServletRequest request, HttpServletResponse response,
552             Portlet portlet, String queryString, String columnId,
553             Integer columnPos, Integer columnCount)
554         throws IOException, ServletException;
555 
556     public void renderPortlet(
557             StringBuilder sb, ServletContext servletContext,
558             HttpServletRequest request, HttpServletResponse response,
559             Portlet portlet, String queryString, String columnId,
560             Integer columnPos, Integer columnCount, String path)
561         throws IOException, ServletException;
562 
563     public void sendError(
564             Exception e, ActionRequest actionRequest,
565             ActionResponse actionResponse)
566         throws IOException;
567 
568     public void sendError(
569             Exception e, HttpServletRequest request,
570             HttpServletResponse response)
571         throws IOException, ServletException;
572 
573     public void sendError(
574             int status, Exception e, ActionRequest actionRequest,
575             ActionResponse actionResponse)
576         throws IOException;
577 
578     public void sendError(
579             int status, Exception e, HttpServletRequest request,
580             HttpServletResponse response)
581         throws IOException, ServletException;
582 
583     /**
584      * Sets the description for a page. This overrides the existing page
585      * description.
586      */
587     public void setPageDescription(
588         String description, HttpServletRequest request);
589 
590     /**
591      * Sets the keywords for a page. This overrides the existing page keywords.
592      */
593     public void setPageKeywords(String keywords, HttpServletRequest request);
594 
595     /**
596      * Sets the subtitle for a page. This overrides the existing page subtitle.
597      */
598     public void setPageSubtitle(String subtitle, HttpServletRequest request);
599 
600     /**
601      * Sets the whole title for a page. This overrides the existing page whole
602      * title.
603      */
604     public void setPageTitle(String title, HttpServletRequest request);
605 
606     /**
607      * Sets the port obtained on the first request to the portal.
608      */
609     public void setPortalPort(HttpServletRequest request);
610 
611     public void storePreferences(PortletPreferences preferences)
612         throws IOException, ValidatorException;
613 
614     public String transformCustomSQL(String sql);
615 
616     public PortletMode updatePortletMode(
617         String portletId, User user, Layout layout, PortletMode portletMode,
618         HttpServletRequest request);
619 
620     public WindowState updateWindowState(
621         String portletId, User user, Layout layout, WindowState windowState,
622         HttpServletRequest request);
623 
624 }