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