1
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.bean.BeanLocatorUtil;
28 import com.liferay.portal.kernel.util.StringMaker;
29 import com.liferay.portal.model.Company;
30 import com.liferay.portal.model.Layout;
31 import com.liferay.portal.model.LayoutSet;
32 import com.liferay.portal.model.Portlet;
33 import com.liferay.portal.model.User;
34 import com.liferay.portal.theme.ThemeDisplay;
35
36 import java.io.IOException;
37
38 import java.rmi.RemoteException;
39
40 import java.util.Date;
41 import java.util.Locale;
42 import java.util.Map;
43 import java.util.TimeZone;
44
45 import javax.portlet.ActionRequest;
46 import javax.portlet.ActionResponse;
47 import javax.portlet.PortletMode;
48 import javax.portlet.PortletPreferences;
49 import javax.portlet.PortletRequest;
50 import javax.portlet.PortletResponse;
51 import javax.portlet.PreferencesValidator;
52 import javax.portlet.RenderRequest;
53 import javax.portlet.ValidatorException;
54 import javax.portlet.WindowState;
55
56 import javax.servlet.ServletContext;
57 import javax.servlet.ServletException;
58 import javax.servlet.http.HttpServletRequest;
59 import javax.servlet.http.HttpServletResponse;
60 import javax.servlet.http.HttpSession;
61
62
68 public class PortalUtil {
69
70 public static void clearRequestParameters(RenderRequest req) {
71 getPortal().clearRequestParameters(req);
72 }
73
74 public static void copyRequestParameters(
75 ActionRequest req, ActionResponse res) {
76
77 getPortal().copyRequestParameters(req, res);
78 }
79
80 public static String getCDNHost() {
81 return getPortal().getCDNHost();
82 }
83
84 public static String getClassName(long classNameId) {
85 return getPortal().getClassName(classNameId);
86 }
87
88 public static long getClassNameId(Class<?> classObj) {
89 return getPortal().getClassNameId(classObj);
90 }
91
92 public static long getClassNameId(String value) {
93 return getPortal().getClassNameId(value);
94 }
95
96 public static String getClassNamePortletId(String className) {
97 return getPortal().getClassNamePortletId(className);
98 }
99
100 public static String getCommunityLoginURL(ThemeDisplay themeDisplay)
101 throws PortalException, SystemException {
102
103 return getPortal().getCommunityLoginURL(themeDisplay);
104 }
105
106 public static Company getCompany(HttpServletRequest req)
107 throws PortalException, SystemException {
108
109 return getPortal().getCompany(req);
110 }
111
112 public static Company getCompany(ActionRequest req)
113 throws PortalException, SystemException {
114
115 return getPortal().getCompany(req);
116 }
117
118 public static Company getCompany(RenderRequest req)
119 throws PortalException, SystemException {
120
121 return getPortal().getCompany(req);
122 }
123
124 public static long getCompanyId(HttpServletRequest req) {
125 return getPortal().getCompanyId(req);
126 }
127
128 public static long getCompanyId(ActionRequest req) {
129 return getPortal().getCompanyId(req);
130 }
131
132 public static long getCompanyId(PortletRequest req) {
133 return getPortal().getCompanyId(req);
134 }
135
136 public static long getCompanyId(RenderRequest req) {
137 return getPortal().getCompanyId(req);
138 }
139
140 public static long getCompanyIdByWebId(ServletContext ctx) {
141 return getPortal().getCompanyIdByWebId(ctx);
142 }
143
144 public static long getCompanyIdByWebId(String webId) {
145 return getPortal().getCompanyIdByWebId(webId);
146 }
147
148 public static String getComputerName() {
149 return getPortal().getComputerName();
150 }
151
152 public static String getCurrentURL(HttpServletRequest req) {
153 return getPortal().getCurrentURL(req);
154 }
155
156 public static String getCurrentURL(PortletRequest req) {
157 return getPortal().getCurrentURL(req);
158 }
159
160 public static Date getDate(int month, int day, int year, PortalException pe)
161 throws PortalException {
162
163 return getPortal().getDate(month, day, year, pe);
164 }
165
166 public static Date getDate(
167 int month, int day, int year, TimeZone timeZone, PortalException pe)
168 throws PortalException {
169
170 return getPortal().getDate(month, day, year, timeZone, pe);
171 }
172
173 public static Date getDate(
174 int month, int day, int year, int hour, int min, PortalException pe)
175 throws PortalException {
176
177 return getPortal().getDate(month, day, year, hour, min, pe);
178 }
179
180 public static Date getDate(
181 int month, int day, int year, int hour, int min, TimeZone timeZone,
182 PortalException pe)
183 throws PortalException {
184
185 return getPortal().getDate(month, day, year, hour, min, timeZone, pe);
186 }
187
188 public static String getHost(HttpServletRequest req) {
189 return getPortal().getHost(req);
190 }
191
192 public static String getHost(ActionRequest req) {
193 return getPortal().getHost(req);
194 }
195
196 public static String getHost(RenderRequest req) {
197 return getPortal().getHost(req);
198 }
199
200 public static HttpServletRequest getHttpServletRequest(PortletRequest req) {
201 return getPortal().getHttpServletRequest(req);
202 }
203
204 public static HttpServletResponse getHttpServletResponse(
205 PortletResponse res) {
206
207 return getPortal().getHttpServletResponse(res);
208 }
209
210 public static String getLayoutEditPage(Layout layout) {
211 return getPortal().getLayoutEditPage(layout);
212 }
213
214 public static String getLayoutViewPage(Layout layout) {
215 return getPortal().getLayoutViewPage(layout);
216 }
217
218 public static String getLayoutURL(ThemeDisplay themeDisplay)
219 throws PortalException, SystemException {
220
221 return getPortal().getLayoutURL(themeDisplay);
222 }
223
224 public static String getLayoutURL(Layout layout, ThemeDisplay themeDisplay)
225 throws PortalException, SystemException {
226
227 return getPortal().getLayoutURL(layout, themeDisplay);
228 }
229
230 public static String getLayoutURL(
231 Layout layout, ThemeDisplay themeDisplay, boolean doAsUser)
232 throws PortalException, SystemException {
233
234 return getPortal().getLayoutURL(layout, themeDisplay, doAsUser);
235 }
236
237 public static String getLayoutActualURL(Layout layout)
238 throws PortalException, SystemException {
239
240 return getPortal().getLayoutActualURL(layout);
241 }
242
243 public static String getLayoutActualURL(Layout layout, String mainPath)
244 throws PortalException, SystemException {
245
246 return getPortal().getLayoutActualURL(layout, mainPath);
247 }
248
249 public static String getLayoutActualURL(
250 long groupId, boolean privateLayout, String mainPath,
251 String friendlyURL)
252 throws PortalException, SystemException {
253
254 return getPortal().getLayoutActualURL(
255 groupId, privateLayout, mainPath, friendlyURL);
256 }
257
258 public static String getLayoutActualURL(
259 long groupId, boolean privateLayout, String mainPath,
260 String friendlyURL, Map<String, String[]> params)
261 throws PortalException, SystemException {
262
263 return getPortal().getLayoutActualURL(
264 groupId, privateLayout, mainPath, friendlyURL, params);
265 }
266
267 public static String getLayoutFriendlyURL(
268 Layout layout, ThemeDisplay themeDisplay)
269 throws PortalException, SystemException {
270
271 return getPortal().getLayoutFriendlyURL(layout, themeDisplay);
272 }
273
274 public static String getLayoutSetFriendlyURL(
275 LayoutSet layoutSet, ThemeDisplay themeDisplay)
276 throws PortalException, SystemException {
277
278 return getPortal().getLayoutSetFriendlyURL(layoutSet, themeDisplay);
279 }
280
281 public static String getLayoutTarget(Layout layout) {
282 return getPortal().getLayoutTarget(layout);
283 }
284
285 public static String getJsSafePortletId(String portletId) {
286 return getPortal().getJsSafePortletId(portletId);
287 }
288
289 public static Locale getLocale(HttpServletRequest req) {
290 return getPortal().getLocale(req);
291 }
292
293 public static Locale getLocale(RenderRequest req) {
294 return getPortal().getLocale(req);
295 }
296
297 public static HttpServletRequest getOriginalServletRequest(
298 HttpServletRequest req) {
299
300 return getPortal().getOriginalServletRequest(req);
301 }
302
303 public static String getPathContext() {
304 return getPortal().getPathContext();
305 }
306
307 public static String getPathFriendlyURLPrivateGroup() {
308 return getPortal().getPathFriendlyURLPrivateGroup();
309 }
310
311 public static String getPathFriendlyURLPrivateUser() {
312 return getPortal().getPathFriendlyURLPrivateUser();
313 }
314
315 public static String getPathFriendlyURLPublic() {
316 return getPortal().getPathFriendlyURLPublic();
317 }
318
319 public static String getPathImage() {
320 return getPortal().getPathImage();
321 }
322
323 public static String getPathMain() {
324 return getPortal().getPathMain();
325 }
326
327 public static long getPlidIdFromFriendlyURL(
328 long companyId, String friendlyURL) {
329
330 return getPortal().getPlidIdFromFriendlyURL(companyId, friendlyURL);
331 }
332
333 public static Portal getPortal() {
334 return _getUtil()._portal;
335 }
336
337 public static String getPortalLibDir() {
338 return getPortal().getPortalLibDir();
339 }
340
341 public static String getPortalURL(ThemeDisplay themeDisplay) {
342 return getPortal().getPortalURL(themeDisplay);
343 }
344
345 public static String getPortalURL(HttpServletRequest req) {
346 return getPortal().getPortalURL(req);
347 }
348
349 public static String getPortalURL(HttpServletRequest req, boolean secure) {
350 return getPortal().getPortalURL(req, secure);
351 }
352
353 public static String getPortalURL(PortletRequest req) {
354 return getPortal().getPortalURL(req);
355 }
356
357 public static String getPortalURL(PortletRequest req, boolean secure) {
358 return getPortal().getPortalURL(req, secure);
359 }
360
361 public static String getPortalURL(
362 String serverName, int serverPort, boolean secure) {
363
364 return getPortal().getPortalURL(serverName, serverPort, secure);
365 }
366
367 public static Object[] getPortletFriendlyURLMapper(
368 long groupId, boolean privateLayout, String url)
369 throws PortalException, SystemException {
370
371 return getPortal().getPortletFriendlyURLMapper(
372 groupId, privateLayout, url);
373 }
374
375 public static Object[] getPortletFriendlyURLMapper(
376 long groupId, boolean privateLayout, String url,
377 Map<String, String[]> params)
378 throws PortalException, SystemException {
379
380 return getPortal().getPortletFriendlyURLMapper(
381 groupId, privateLayout, url, params);
382 }
383
384 public static long getPortletGroupId(long plid) {
385 return getPortal().getPortletGroupId(plid);
386 }
387
388 public static long getPortletGroupId(Layout layout) {
389 return getPortal().getPortletGroupId(layout);
390 }
391
392 public static long getPortletGroupId(HttpServletRequest req) {
393 return getPortal().getPortletGroupId(req);
394 }
395
396 public static long getPortletGroupId(ActionRequest req) {
397 return getPortal().getPortletGroupId(req);
398 }
399
400 public static long getPortletGroupId(RenderRequest req) {
401 return getPortal().getPortletGroupId(req);
402 }
403
404 public static String getPortletNamespace(String portletId) {
405 return getPortal().getPortletNamespace(portletId);
406 }
407
408 public static String getPortletTitle(
409 String portletId, long companyId, String languageId) {
410
411 return getPortal().getPortletTitle(portletId, companyId, languageId);
412 }
413
414 public static String getPortletTitle(
415 String portletId, long companyId, Locale locale) {
416
417 return getPortal().getPortletTitle(portletId, companyId, locale);
418 }
419
420 public static String getPortletTitle(String portletId, User user) {
421 return getPortal().getPortletTitle(portletId, user);
422 }
423
424 public static String getPortletTitle(
425 Portlet portlet, ServletContext ctx, Locale locale) {
426
427 return getPortal().getPortletTitle(portlet, ctx, locale);
428 }
429
430 public static String getPortletXmlFileName()
431 throws PortalException, SystemException {
432
433 return getPortal().getPortletXmlFileName();
434 }
435
436 public static PortletPreferences getPreferences(HttpServletRequest req) {
437 return getPortal().getPreferences(req);
438 }
439
440 public static PreferencesValidator getPreferencesValidator(
441 Portlet portlet) {
442
443 return getPortal().getPreferencesValidator(portlet);
444 }
445
446 public static User getSelectedUser(HttpServletRequest req)
447 throws PortalException, RemoteException, SystemException {
448
449 return getPortal().getSelectedUser(req);
450 }
451
452 public static User getSelectedUser(
453 HttpServletRequest req, boolean checkPermission)
454 throws PortalException, RemoteException, SystemException {
455
456 return getPortal().getSelectedUser(req, checkPermission);
457 }
458
459 public static User getSelectedUser(ActionRequest req)
460 throws PortalException, RemoteException, SystemException {
461
462 return getPortal().getSelectedUser(req);
463 }
464
465 public static User getSelectedUser(
466 ActionRequest req, boolean checkPermission)
467 throws PortalException, RemoteException, SystemException {
468
469 return getPortal().getSelectedUser(req, checkPermission);
470 }
471
472 public static User getSelectedUser(RenderRequest req)
473 throws PortalException, RemoteException, SystemException {
474
475 return getPortal().getSelectedUser(req);
476 }
477
478 public static User getSelectedUser(
479 RenderRequest req, boolean checkPermission)
480 throws PortalException, RemoteException, SystemException {
481
482 return getPortal().getSelectedUser(req, checkPermission);
483 }
484
485 public static String getStrutsAction(HttpServletRequest req) {
486 return getPortal().getStrutsAction(req);
487 }
488
489 public static String[] getSystemCommunityRoles() {
490 return getPortal().getSystemCommunityRoles();
491 }
492
493 public static String[] getSystemGroups() {
494 return getPortal().getSystemGroups();
495 }
496
497 public static String[] getSystemOrganizationRoles() {
498 return getPortal().getSystemOrganizationRoles();
499 }
500
501 public static String[] getSystemRoles() {
502 return getPortal().getSystemRoles();
503 }
504
505 public static Date getUptime() {
506 return getPortal().getUptime();
507 }
508
509 public static String getURLWithSessionId(String url, String sessionId) {
510 return getPortal().getURLWithSessionId(url, sessionId);
511 }
512
513 public static User getUser(HttpServletRequest req)
514 throws PortalException, SystemException {
515
516 return getPortal().getUser(req);
517 }
518
519 public static User getUser(ActionRequest req)
520 throws PortalException, SystemException {
521
522 return getPortal().getUser(req);
523 }
524
525 public static User getUser(RenderRequest req)
526 throws PortalException, SystemException {
527
528 return getPortal().getUser(req);
529 }
530
531 public static long getUserId(HttpServletRequest req) {
532 return getPortal().getUserId(req);
533 }
534
535 public static long getUserId(ActionRequest req) {
536 return getPortal().getUserId(req);
537 }
538
539 public static long getUserId(RenderRequest req) {
540 return getPortal().getUserId(req);
541 }
542
543 public static String getUserName(long userId, String defaultUserName) {
544 return getPortal().getUserName(userId, defaultUserName);
545 }
546
547 public static String getUserName(
548 long userId, String defaultUserName, String userAttribute) {
549
550 return getPortal().getUserName(userId, defaultUserName, userAttribute);
551 }
552
553 public static String getUserName(
554 long userId, String defaultUserName, HttpServletRequest req) {
555
556 return getPortal().getUserName(userId, defaultUserName, req);
557 }
558
559 public static String getUserName(
560 long userId, String defaultUserName, String userAttribute,
561 HttpServletRequest req) {
562
563 return getPortal().getUserName(
564 userId, defaultUserName, userAttribute, req);
565 }
566
567 public static String getUserPassword(HttpSession ses) {
568 return getPortal().getUserPassword(ses);
569 }
570
571 public static String getUserPassword(HttpServletRequest req) {
572 return getPortal().getUserPassword(req);
573 }
574
575 public static String getUserPassword(ActionRequest req) {
576 return getPortal().getUserPassword(req);
577 }
578
579 public static String getUserPassword(RenderRequest req) {
580 return getPortal().getUserPassword(req);
581 }
582
583 public static String getUserValue(
584 long userId, String param, String defaultValue)
585 throws SystemException {
586
587 return getPortal().getUserValue(userId, param, defaultValue);
588 }
589
590 public static boolean isMethodGet(PortletRequest req) {
591 return getPortal().isMethodGet(req);
592 }
593
594 public static boolean isMethodPost(PortletRequest req) {
595 return getPortal().isMethodPost(req);
596 }
597
598 public static boolean isLayoutFriendliable(Layout layout) {
599 return getPortal().isLayoutFriendliable(layout);
600 }
601
602 public static boolean isLayoutParentable(Layout layout) {
603 return getPortal().isLayoutParentable(layout);
604 }
605
606 public static boolean isLayoutParentable(String type) {
607 return getPortal().isLayoutParentable(type);
608 }
609
610 public static boolean isLayoutSitemapable(Layout layout) {
611 return getPortal().isLayoutSitemapable(layout);
612 }
613
614 public static boolean isReservedParameter(String name) {
615 return getPortal().isReservedParameter(name);
616 }
617
618 public static boolean isSystemGroup(String groupName) {
619 return getPortal().isSystemGroup(groupName);
620 }
621
622 public static boolean isSystemRole(String roleName) {
623 return getPortal().isSystemRole(roleName);
624 }
625
626 public static boolean isUpdateAvailable()
627 throws PortalException, SystemException {
628
629 return getPortal().isUpdateAvailable();
630 }
631
632 public static void renderPage(
633 StringMaker sm, ServletContext ctx, HttpServletRequest req,
634 HttpServletResponse res, String path)
635 throws IOException, ServletException {
636
637 getPortal().renderPage(sm, ctx, req, res, path);
638 }
639
640 public static void renderPortlet(
641 StringMaker sm, ServletContext ctx, HttpServletRequest req,
642 HttpServletResponse res, Portlet portlet, String queryString)
643 throws IOException, ServletException {
644
645 getPortal().renderPortlet(
646 sm, ctx, req, res, portlet, queryString);
647 }
648
649 public static void renderPortlet(
650 StringMaker sm, ServletContext ctx, HttpServletRequest req,
651 HttpServletResponse res, Portlet portlet, String queryString,
652 String columnId, Integer columnPos, Integer columnCount)
653 throws IOException, ServletException {
654
655 getPortal().renderPortlet(
656 sm, ctx, req, res, portlet, queryString, columnId, columnPos,
657 columnCount);
658 }
659
660 public static void renderPortlet(
661 StringMaker sm, ServletContext ctx, HttpServletRequest req,
662 HttpServletResponse res, Portlet portlet, String queryString,
663 String columnId, Integer columnPos, Integer columnCount,
664 String path)
665 throws IOException, ServletException {
666
667 getPortal().renderPortlet(
668 sm, ctx, req, res, portlet, queryString, columnId, columnPos,
669 columnCount, path);
670 }
671
672 public static void sendError(
673 int status, Exception e, HttpServletRequest req,
674 HttpServletResponse res)
675 throws IOException, ServletException {
676
677 getPortal().sendError(status, e, req, res);
678 }
679
680
687 public static void setPageSubtitle(
688 String subtitle, HttpServletRequest req) {
689
690 getPortal().setPageSubtitle(subtitle, req);
691 }
692
693
700 public static void setPageTitle(String title, HttpServletRequest req) {
701 getPortal().setPageTitle(title, req);
702 }
703
704 public static void storePreferences(PortletPreferences prefs)
705 throws IOException, ValidatorException {
706
707 getPortal().storePreferences(prefs);
708 }
709
710 public static PortletMode updatePortletMode(
711 String portletId, User user, Layout layout, PortletMode portletMode,
712 HttpServletRequest req)
713 throws PortalException, RemoteException, SystemException {
714
715 return getPortal().updatePortletMode(
716 portletId, user, layout, portletMode, req);
717 }
718
719 public static WindowState updateWindowState(
720 String portletId, User user, Layout layout, WindowState windowState,
721 HttpServletRequest req)
722 throws PortalException, RemoteException, SystemException {
723
724 return getPortal().updateWindowState(
725 portletId, user, layout, windowState, req);
726 }
727
728 public void setPortal(Portal portal) {
729 _portal = portal;
730 }
731
732 private static PortalUtil _getUtil() {
733 if (_util == null) {
734 _util = (PortalUtil)BeanLocatorUtil.locate(_UTIL);
735 }
736
737 return _util;
738 }
739
740 private static final String _UTIL = PortalUtil.class.getName();
741
742 private static PortalUtil _util;
743
744 private Portal _portal;
745
746 }