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