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