001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.util;
016    
017    import com.liferay.portal.kernel.language.LanguageUtil;
018    import com.liferay.portal.kernel.servlet.DirectRequestDispatcherFactoryUtil;
019    import com.liferay.portal.kernel.servlet.PipingPageContext;
020    import com.liferay.portal.kernel.servlet.taglib.TagSupport;
021    import com.liferay.portal.kernel.templateparser.TemplateContext;
022    import com.liferay.portal.kernel.util.HttpUtil;
023    import com.liferay.portal.kernel.util.WebKeys;
024    import com.liferay.portal.model.Layout;
025    import com.liferay.portal.model.LayoutConstants;
026    import com.liferay.portal.model.Portlet;
027    import com.liferay.portal.theme.ThemeDisplay;
028    import com.liferay.taglib.aui.ColumnTag;
029    import com.liferay.taglib.aui.LayoutTag;
030    import com.liferay.taglib.portlet.ActionURLTag;
031    import com.liferay.taglib.portletext.IconBackTag;
032    import com.liferay.taglib.portletext.IconCloseTag;
033    import com.liferay.taglib.portletext.IconConfigurationTag;
034    import com.liferay.taglib.portletext.IconEditDefaultsTag;
035    import com.liferay.taglib.portletext.IconEditGuestTag;
036    import com.liferay.taglib.portletext.IconEditTag;
037    import com.liferay.taglib.portletext.IconHelpTag;
038    import com.liferay.taglib.portletext.IconMaximizeTag;
039    import com.liferay.taglib.portletext.IconMinimizeTag;
040    import com.liferay.taglib.portletext.IconOptionsTag;
041    import com.liferay.taglib.portletext.IconPortletCssTag;
042    import com.liferay.taglib.portletext.IconPortletTag;
043    import com.liferay.taglib.portletext.IconPrintTag;
044    import com.liferay.taglib.portletext.IconRefreshTag;
045    import com.liferay.taglib.portletext.RuntimeTag;
046    import com.liferay.taglib.security.DoAsURLTag;
047    import com.liferay.taglib.security.PermissionsURLTag;
048    import com.liferay.taglib.theme.LayoutIconTag;
049    import com.liferay.taglib.theme.MetaTagsTag;
050    import com.liferay.taglib.theme.WrapPortletTag;
051    import com.liferay.taglib.ui.AssetCategoriesSummaryTag;
052    import com.liferay.taglib.ui.AssetLinksTag;
053    import com.liferay.taglib.ui.AssetTagsSummaryTag;
054    import com.liferay.taglib.ui.BreadcrumbTag;
055    import com.liferay.taglib.ui.DiscussionTag;
056    import com.liferay.taglib.ui.FlagsTag;
057    import com.liferay.taglib.ui.IconTag;
058    import com.liferay.taglib.ui.JournalArticleTag;
059    import com.liferay.taglib.ui.JournalContentSearchTag;
060    import com.liferay.taglib.ui.LanguageTag;
061    import com.liferay.taglib.ui.MySitesTag;
062    import com.liferay.taglib.ui.PngImageTag;
063    import com.liferay.taglib.ui.RatingsTag;
064    import com.liferay.taglib.ui.SearchTag;
065    import com.liferay.taglib.ui.SitesDirectoryTag;
066    import com.liferay.taglib.ui.SocialBookmarksTag;
067    import com.liferay.taglib.ui.StagingTag;
068    import com.liferay.taglib.ui.ToggleTag;
069    
070    import java.io.Writer;
071    
072    import java.util.Map;
073    import java.util.Set;
074    
075    import javax.portlet.PortletMode;
076    import javax.portlet.PortletRequest;
077    import javax.portlet.PortletURL;
078    import javax.portlet.WindowState;
079    
080    import javax.servlet.RequestDispatcher;
081    import javax.servlet.ServletContext;
082    import javax.servlet.http.HttpServletRequest;
083    import javax.servlet.http.HttpServletResponse;
084    import javax.servlet.jsp.PageContext;
085    
086    /**
087     * @author Brian Wing Shun Chan
088     * @author Shuyang Zhou
089     */
090    public class VelocityTaglibImpl implements VelocityTaglib {
091    
092            public VelocityTaglibImpl() {
093            }
094    
095            public VelocityTaglibImpl(
096                    ServletContext servletContext, HttpServletRequest request,
097                    HttpServletResponse response, PageContext pageContext,
098                    TemplateContext templateContext) {
099    
100                    init(servletContext, request, response, pageContext, templateContext);
101            }
102    
103            public void actionURL(long plid, String portletName, String queryString)
104                    throws Exception {
105    
106                    String windowState = WindowState.NORMAL.toString();
107                    String portletMode = PortletMode.VIEW.toString();
108    
109                    actionURL(windowState, portletMode, plid, portletName, queryString);
110            }
111    
112            public void actionURL(String portletName, String queryString)
113                    throws Exception {
114    
115                    actionURL(LayoutConstants.DEFAULT_PLID, portletName, queryString);
116            }
117    
118            /**
119             * @deprecated {@link #actionURL(String, String, Boolean, Boolean, Boolean,
120             *             String, long, long, String, Boolean, Boolean, long, long,
121             *             Boolean, String)}
122             */
123            public void actionURL(
124                            String windowState, String portletMode, Boolean secure,
125                            Boolean copyCurrentRenderParameters, Boolean escapeXml, String name,
126                            long plid, long refererPlid, String portletName, Boolean anchor,
127                            Boolean encrypt, long doAsUserId, Boolean portletConfiguration,
128                            String queryString)
129                    throws Exception {
130    
131                    actionURL(
132                            windowState, portletMode, secure, copyCurrentRenderParameters,
133                            escapeXml, name, plid, refererPlid, portletName, anchor, encrypt, 0,
134                            doAsUserId, portletConfiguration, queryString);
135            }
136    
137            public void actionURL(
138                            String windowState, String portletMode, Boolean secure,
139                            Boolean copyCurrentRenderParameters, Boolean escapeXml, String name,
140                            long plid, long refererPlid, String portletName, Boolean anchor,
141                            Boolean encrypt, long doAsGroupId, long doAsUserId,
142                            Boolean portletConfiguration, String queryString)
143                    throws Exception {
144    
145                    String var = null;
146                    String varImpl = null;
147                    String resourceID = null;
148                    String cacheability = null;
149                    Map<String, String[]> parameterMap = HttpUtil.parameterMapFromString(
150                            queryString);
151                    Set<String> removedParameterNames = null;
152    
153                    ActionURLTag.doTag(
154                            PortletRequest.ACTION_PHASE, windowState, portletMode, var, varImpl,
155                            secure, copyCurrentRenderParameters, escapeXml, name, resourceID,
156                            cacheability, plid, refererPlid, portletName, anchor, encrypt,
157                            doAsGroupId, doAsUserId, portletConfiguration, parameterMap,
158                            removedParameterNames, _pageContext);
159            }
160    
161            public void actionURL(
162                            String windowState, String portletMode, long plid,
163                            String portletName, String queryString)
164                    throws Exception {
165    
166                    Boolean secure = null;
167                    Boolean copyCurrentRenderParameters = null;
168                    Boolean escapeXml = null;
169                    long refererPlid = LayoutConstants.DEFAULT_PLID;
170                    String name = null;
171                    Boolean anchor = null;
172                    Boolean encrypt = null;
173                    long doAsGroupId = 0;
174                    long doAsUserId = 0;
175                    Boolean portletConfiguration = null;
176    
177                    actionURL(
178                            windowState, portletMode, secure, copyCurrentRenderParameters,
179                            escapeXml, name, plid, refererPlid, portletName, anchor, encrypt,
180                            doAsGroupId, doAsUserId, portletConfiguration, queryString);
181            }
182    
183            public void actionURL(
184                            String windowState, String portletMode, String portletName,
185                            String queryString)
186                    throws Exception {
187    
188                    actionURL(
189                            windowState, portletMode, LayoutConstants.DEFAULT_PLID, portletName,
190                            queryString);
191            }
192    
193            public void assetCategoriesSummary(
194                            String className, long classPK, String message,
195                            PortletURL portletURL)
196                    throws Exception {
197    
198                    AssetCategoriesSummaryTag assetCategorySummaryTag =
199                            new AssetCategoriesSummaryTag();
200    
201                    setUp(assetCategorySummaryTag);
202    
203                    assetCategorySummaryTag.setClassName(className);
204                    assetCategorySummaryTag.setClassPK(classPK);
205                    assetCategorySummaryTag.setMessage(message);
206                    assetCategorySummaryTag.setPortletURL(portletURL);
207    
208                    assetCategorySummaryTag.runTag();
209            }
210    
211            public void assetLinks(long assetEntryId, String className, long classPK)
212                    throws Exception {
213    
214                    AssetLinksTag assetLinksTag = new AssetLinksTag();
215    
216                    setUp(assetLinksTag);
217    
218                    assetLinksTag.setAssetEntryId(assetEntryId);
219                    assetLinksTag.setClassName(className);
220                    assetLinksTag.setClassPK(classPK);
221    
222                    assetLinksTag.runTag();
223            }
224    
225            public void assetTagsSummary(
226                            String className, long classPK, String message,
227                            String assetTagNames, PortletURL portletURL)
228                    throws Exception {
229    
230                    AssetTagsSummaryTag assetTagsSummaryTag = new AssetTagsSummaryTag();
231    
232                    setUp(assetTagsSummaryTag);
233    
234                    assetTagsSummaryTag.setClassName(className);
235                    assetTagsSummaryTag.setClassPK(classPK);
236                    assetTagsSummaryTag.setMessage(message);
237                    assetTagsSummaryTag.setPortletURL(portletURL);
238                    assetTagsSummaryTag.setAssetTagNames(assetTagNames);
239    
240                    assetTagsSummaryTag.runTag();
241            }
242    
243            public void breadcrumb() throws Exception {
244                    BreadcrumbTag breadcrumbTag = new BreadcrumbTag();
245    
246                    setUp(breadcrumbTag);
247    
248                    breadcrumbTag.runTag();
249            }
250    
251            public void breadcrumb(
252                            String displayStyle, boolean showGuestGroup,
253                            boolean showParentGroups, boolean showLayout,
254                            boolean showPortletBreadcrumb)
255                    throws Exception {
256    
257                    BreadcrumbTag breadcrumbTag = new BreadcrumbTag();
258    
259                    setUp(breadcrumbTag);
260    
261                    breadcrumbTag.setDisplayStyle(displayStyle);
262                    breadcrumbTag.setShowGuestGroup(showGuestGroup);
263                    breadcrumbTag.setShowLayout(showLayout);
264                    breadcrumbTag.setShowParentGroups(showParentGroups);
265                    breadcrumbTag.setShowPortletBreadcrumb(showPortletBreadcrumb);
266    
267                    breadcrumbTag.runTag();
268            }
269    
270            public void discussion(
271                            String className, long classPK, String formAction, String formName,
272                            boolean hideControls, boolean ratingsEnabled, String redirect,
273                            String subject, long userId)
274                    throws Exception {
275    
276                    DiscussionTag discussionTag = new DiscussionTag();
277    
278                    setUp(discussionTag);
279    
280                    discussionTag.setClassName(className);
281                    discussionTag.setClassPK(classPK);
282                    discussionTag.setFormAction(formAction);
283                    discussionTag.setFormName(formName);
284                    discussionTag.setHideControls(hideControls);
285                    discussionTag.setRatingsEnabled(ratingsEnabled);
286                    discussionTag.setRedirect(redirect);
287                    discussionTag.setSubject(subject);
288                    discussionTag.setUserId(userId);
289    
290                    discussionTag.runTag();
291            }
292    
293            public void doAsURL(long doAsUserId) throws Exception {
294                    DoAsURLTag.doTag(doAsUserId, null, _pageContext);
295            }
296    
297            public void flags(
298                            String className, long classPK, String contentTitle, boolean label,
299                            String message, long reportedUserId)
300                    throws Exception {
301    
302                    FlagsTag flagsTag = new FlagsTag();
303    
304                    setUp(flagsTag);
305    
306                    flagsTag.setClassName(className);
307                    flagsTag.setClassPK(classPK);
308                    flagsTag.setContentTitle(contentTitle);
309                    flagsTag.setLabel(label);
310                    flagsTag.setMessage(message);
311                    flagsTag.setReportedUserId(reportedUserId);
312    
313                    flagsTag.runTag();
314            }
315    
316            public AssetCategoriesSummaryTag getAssetCategoriesSummaryTag()
317                    throws Exception {
318    
319                    AssetCategoriesSummaryTag assetCategoriesSummaryTag =
320                                    new AssetCategoriesSummaryTag();
321    
322                    setUp(assetCategoriesSummaryTag);
323    
324                    return assetCategoriesSummaryTag;
325            }
326    
327            public AssetLinksTag getAssetLinksTag() throws Exception {
328                    AssetLinksTag assetLinksTag = new AssetLinksTag();
329    
330                    setUp(assetLinksTag);
331    
332                    return assetLinksTag;
333            }
334    
335            public AssetTagsSummaryTag getAssetTagsSummaryTag() throws Exception {
336                    AssetTagsSummaryTag assetTagsSummaryTag = new AssetTagsSummaryTag();
337    
338                    setUp(assetTagsSummaryTag);
339    
340                    return assetTagsSummaryTag;
341            }
342    
343            public BreadcrumbTag getBreadcrumbTag() throws Exception {
344                    BreadcrumbTag breadcrumbTag = new BreadcrumbTag();
345    
346                    setUp(breadcrumbTag);
347    
348                    return breadcrumbTag;
349            }
350    
351            public ColumnTag getColumnTag() throws Exception {
352                    ColumnTag columnTag = new ColumnTag();
353    
354                    setUp(columnTag);
355    
356                    return columnTag;
357            }
358    
359            public DiscussionTag getDiscussionTag() throws Exception {
360                    DiscussionTag discussionTag = new DiscussionTag();
361    
362                    setUp(discussionTag);
363    
364                    return discussionTag;
365            }
366    
367            public FlagsTag getFlagsTag() throws Exception {
368                    FlagsTag flagsTag = new FlagsTag();
369    
370                    setUp(flagsTag);
371    
372                    return flagsTag;
373            }
374    
375            public IconTag getIconTag() throws Exception {
376                    IconTag iconTag = new IconTag();
377    
378                    setUp(iconTag);
379    
380                    return iconTag;
381            }
382    
383            public JournalArticleTag getJournalArticleTag() throws Exception {
384                    JournalArticleTag journalArticleTag = new JournalArticleTag();
385    
386                    setUp(journalArticleTag);
387    
388                    return journalArticleTag;
389            }
390    
391            public LayoutTag getLayoutTag() throws Exception {
392                    LayoutTag layoutTag = new LayoutTag();
393    
394                    setUp(layoutTag);
395    
396                    return layoutTag;
397            }
398    
399            public MySitesTag getMySitesTag() throws Exception {
400                    MySitesTag mySitesTag = new MySitesTag();
401    
402                    setUp(mySitesTag);
403    
404                    return mySitesTag;
405            }
406    
407            public PngImageTag getPngImageTag() throws Exception {
408                    PngImageTag pngImageTag = new PngImageTag();
409    
410                    setUp(pngImageTag);
411    
412                    return pngImageTag;
413            }
414    
415            public RatingsTag getRatingsTag() throws Exception {
416                    RatingsTag ratingsTag = new RatingsTag();
417    
418                    setUp(ratingsTag);
419    
420                    return ratingsTag;
421            }
422    
423            public String getSetting(String name) {
424                    ThemeDisplay themeDisplay = (ThemeDisplay)_request.getAttribute(
425                            WebKeys.THEME_DISPLAY);
426    
427                    return themeDisplay.getThemeSetting(name);
428            }
429    
430            public WindowState getWindowState(String windowState) {
431                    return new WindowState(windowState);
432            }
433    
434            public void icon(String image, boolean label, String message, String url)
435                    throws Exception {
436    
437                    IconTag iconTag = new IconTag();
438    
439                    setUp(iconTag);
440    
441                    iconTag.setImage(image);
442                    iconTag.setLabel(label);
443                    iconTag.setMessage(message);
444                    iconTag.setUrl(url);
445    
446                    iconTag.runTag();
447            }
448    
449            public void iconBack() throws Exception {
450                    IconBackTag iconBackTag = new IconBackTag();
451    
452                    setUp(iconBackTag);
453    
454                    iconBackTag.runTag();
455            }
456    
457            public void iconClose() throws Exception {
458                    IconCloseTag iconCloseTag = new IconCloseTag();
459    
460                    setUp(iconCloseTag);
461    
462                    iconCloseTag.runTag();
463            }
464    
465            public void iconConfiguration() throws Exception {
466                    IconConfigurationTag iconConfigurationTag = new IconConfigurationTag();
467    
468                    setUp(iconConfigurationTag);
469    
470                    iconConfigurationTag.runTag();
471            }
472    
473            public void iconEdit() throws Exception {
474                    IconEditTag iconEditTag = new IconEditTag();
475    
476                    setUp(iconEditTag);
477    
478                    iconEditTag.runTag();
479            }
480    
481            public void iconEditDefaults() throws Exception {
482                    IconEditDefaultsTag iconEditDefaultsTag = new IconEditDefaultsTag();
483    
484                    setUp(iconEditDefaultsTag);
485    
486                    iconEditDefaultsTag.runTag();
487            }
488    
489            public void iconEditGuest() throws Exception {
490                    IconEditGuestTag iconEditGuestTag = new IconEditGuestTag();
491    
492                    setUp(iconEditGuestTag);
493    
494                    iconEditGuestTag.runTag();
495            }
496    
497            public void iconHelp() throws Exception {
498                    IconHelpTag iconHelpTag = new IconHelpTag();
499    
500                    setUp(iconHelpTag);
501    
502                    iconHelpTag.runTag();
503            }
504    
505            public void iconMaximize() throws Exception {
506                    IconMaximizeTag iconMaximizeTag = new IconMaximizeTag();
507    
508                    setUp(iconMaximizeTag);
509    
510                    iconMaximizeTag.runTag();
511            }
512    
513            public void iconMinimize() throws Exception {
514                    IconMinimizeTag iconMinimizeTag = new IconMinimizeTag();
515    
516                    setUp(iconMinimizeTag);
517    
518                    iconMinimizeTag.runTag();
519            }
520    
521            public void iconOptions() throws Exception {
522                    IconOptionsTag iconOptionsTag = new IconOptionsTag();
523    
524                    setUp(iconOptionsTag);
525    
526                    iconOptionsTag.runTag();
527            }
528    
529            public void iconPortlet() throws Exception {
530                    IconPortletTag iconPortletTag = new IconPortletTag();
531    
532                    setUp(iconPortletTag);
533    
534                    iconPortletTag.runTag();
535            }
536    
537            public void iconPortlet(Portlet portlet) throws Exception {
538                    IconPortletTag iconPortletTag = new IconPortletTag();
539    
540                    setUp(iconPortletTag);
541    
542                    iconPortletTag.setPortlet(portlet);
543    
544                    iconPortletTag.runTag();
545            }
546    
547            public void iconPortletCss() throws Exception {
548                    IconPortletCssTag iconPortletCssTag = new IconPortletCssTag();
549    
550                    setUp(iconPortletCssTag);
551    
552                    iconPortletCssTag.runTag();
553            }
554    
555            public void iconPrint() throws Exception {
556                    IconPrintTag iconPrintTag = new IconPrintTag();
557    
558                    setUp(iconPrintTag);
559    
560                    iconPrintTag.runTag();
561            }
562    
563            public void iconRefresh() throws Exception {
564                    IconRefreshTag iconRefreshTag = new IconRefreshTag();
565    
566                    setUp(iconRefreshTag);
567    
568                    iconRefreshTag.runTag();
569            }
570    
571            public void include(ServletContext servletContext, String page)
572                    throws Exception {
573    
574                    RequestDispatcher requestDispatcher =
575                            servletContext.getRequestDispatcher(page);
576    
577                    requestDispatcher.include(_request, _response);
578            }
579    
580            public void include(String page) throws Exception {
581                    RequestDispatcher requestDispatcher =
582                            DirectRequestDispatcherFactoryUtil.getRequestDispatcher(
583                                    _servletContext, page);
584    
585                    requestDispatcher.include(_request, _response);
586            }
587    
588            public void journalArticle(
589                            String articleId, long groupId, String templateId)
590                    throws Exception {
591    
592                    JournalArticleTag journalArticleTag = new JournalArticleTag();
593    
594                    setUp(journalArticleTag);
595    
596                    journalArticleTag.setArticleId(articleId);
597                    journalArticleTag.setGroupId(groupId);
598                    journalArticleTag.setLanguageId(LanguageUtil.getLanguageId(_request));
599                    journalArticleTag.setTemplateId(templateId);
600    
601                    journalArticleTag.runTag();
602            }
603    
604            public void journalContentSearch() throws Exception {
605                    journalContentSearch(true, null, null);
606            }
607    
608            public void journalContentSearch(
609                            boolean showListed, String targetPortletId, String type)
610                    throws Exception {
611    
612                    JournalContentSearchTag journalContentSearchTag =
613                            new JournalContentSearchTag();
614    
615                    setUp(journalContentSearchTag);
616    
617                    journalContentSearchTag.setShowListed(showListed);
618                    journalContentSearchTag.setTargetPortletId(targetPortletId);
619                    journalContentSearchTag.setType(type);
620    
621                    journalContentSearchTag.runTag();
622            }
623    
624            public void language() throws Exception {
625                    LanguageTag languageTag = new LanguageTag();
626    
627                    setUp(languageTag);
628    
629                    languageTag.runTag();
630            }
631    
632            public void language(
633                            String formName, String formAction, String name, int displayStyle)
634                    throws Exception {
635    
636                    LanguageTag languageTag = new LanguageTag();
637    
638                    setUp(languageTag);
639    
640                    languageTag.setDisplayStyle(displayStyle);
641                    languageTag.setFormAction(formAction);
642                    languageTag.setFormName(formName);
643                    languageTag.setName(name);
644    
645                    languageTag.runTag();
646            }
647    
648            public void language(
649                            String formName, String formAction, String name,
650                            String[] languageIds, int displayStyle)
651                    throws Exception {
652    
653                    LanguageTag languageTag = new LanguageTag();
654    
655                    setUp(languageTag);
656    
657                    languageTag.setDisplayStyle(displayStyle);
658                    languageTag.setFormAction(formAction);
659                    languageTag.setFormName(formName);
660                    languageTag.setLanguageIds(languageIds);
661                    languageTag.setName(name);
662    
663                    languageTag.runTag();
664            }
665    
666            public void layoutIcon(Layout layout) throws Exception {
667                    LayoutIconTag.doTag(layout, _servletContext, _request, _response);
668            }
669    
670            public void metaTags() throws Exception {
671                    MetaTagsTag.doTag(_servletContext, _request, _response);
672            }
673    
674            /**
675             * @deprecated {@link #mySites}
676             */
677            public void myPlaces() throws Exception {
678                    mySites();
679            }
680    
681            /**
682             * @deprecated {@link #mySites(int)}
683             */
684            public void myPlaces(int max) throws Exception {
685                    mySites(max);
686            }
687    
688            public void mySites() throws Exception {
689                    MySitesTag mySitesTag = new MySitesTag();
690    
691                    setUp(mySitesTag);
692    
693                    mySitesTag.runTag();
694            }
695    
696            public void mySites(int max) throws Exception {
697                    MySitesTag mySitesTag = new MySitesTag();
698    
699                    setUp(mySitesTag);
700    
701                    mySitesTag.setMax(max);
702    
703                    mySitesTag.runTag();
704            }
705    
706            public void permissionsURL(
707                            String redirect, String modelResource,
708                            String modelResourceDescription, Object resourceGroupId,
709                            String resourcePrimKey, String windowState, int[] roleTypes)
710                    throws Exception {
711    
712                    PermissionsURLTag.doTag(
713                            redirect, modelResource, modelResourceDescription, resourceGroupId,
714                            resourcePrimKey, windowState, null, roleTypes, _pageContext);
715            }
716    
717            /**
718             * @deprecated {@link #permissionsURL(String, String, String, long, String,
719             *             String, int[])}
720             */
721            public void permissionsURL(
722                            String redirect, String modelResource,
723                            String modelResourceDescription, String resourcePrimKey,
724                            String windowState, int[] roleTypes)
725                    throws Exception {
726    
727                    permissionsURL(
728                            redirect, modelResourceDescription, modelResourceDescription, null,
729                            resourcePrimKey, windowState, roleTypes);
730            }
731    
732            public void ratings(
733                            String className, long classPK, int numberOfStars, String type,
734                            String url)
735                    throws Exception {
736    
737                    RatingsTag ratingsTag = new RatingsTag();
738    
739                    setUp(ratingsTag);
740    
741                    ratingsTag.setClassName(className);
742                    ratingsTag.setClassPK(classPK);
743                    ratingsTag.setNumberOfStars(numberOfStars);
744                    ratingsTag.setType(type);
745                    ratingsTag.setUrl(url);
746    
747                    ratingsTag.runTag();
748            }
749    
750            public void renderURL(long plid, String portletName, String queryString)
751                    throws Exception {
752    
753                    String windowState = WindowState.NORMAL.toString();
754                    String portletMode = PortletMode.VIEW.toString();
755    
756                    renderURL(windowState, portletMode, plid, portletName, queryString);
757            }
758    
759            public void renderURL(String portletName, String queryString)
760                    throws Exception {
761    
762                    renderURL(LayoutConstants.DEFAULT_PLID, portletName, queryString);
763            }
764    
765            public void renderURL(
766                            String windowState, String portletMode, Boolean secure,
767                            Boolean copyCurrentRenderParameters, Boolean escapeXml, long plid,
768                            long refererPlid, String portletName, Boolean anchor,
769                            Boolean encrypt, long doAsGroupId, long doAsUserId,
770                            Boolean portletConfiguration, String queryString)
771                    throws Exception {
772    
773                    String var = null;
774                    String varImpl = null;
775                    String name = null;
776                    String resourceID = null;
777                    String cacheability = null;
778                    Map<String, String[]> parameterMap = HttpUtil.parameterMapFromString(
779                            queryString);
780                    Set<String> removedParameterNames = null;
781    
782                    ActionURLTag.doTag(
783                            PortletRequest.RENDER_PHASE, windowState, portletMode, var, varImpl,
784                            secure, copyCurrentRenderParameters, escapeXml, name, resourceID,
785                            cacheability, plid, refererPlid, portletName, anchor, encrypt,
786                            doAsGroupId, doAsUserId, portletConfiguration, parameterMap,
787                            removedParameterNames, _pageContext);
788            }
789    
790            /**
791             * @deprecated {@link #renderURL(String, String, Boolean, Boolean, Boolean,
792             *             long, long, String, Boolean, Boolean, long, long, Boolean,
793             *             String)}
794             */
795            public void renderURL(
796                            String windowState, String portletMode, Boolean secure,
797                            Boolean copyCurrentRenderParameters, Boolean escapeXml, long plid,
798                            String portletName, Boolean anchor, Boolean encrypt,
799                            long doAsUserId, Boolean portletConfiguration, String queryString)
800                    throws Exception {
801    
802                    long refererPlid = LayoutConstants.DEFAULT_PLID;
803    
804                    renderURL(
805                            windowState, portletMode, secure, copyCurrentRenderParameters,
806                            escapeXml, plid, refererPlid, portletName, anchor, encrypt, 0,
807                            doAsUserId, portletConfiguration, queryString);
808            }
809    
810            public void renderURL(
811                            String windowState, String portletMode, long plid,
812                            String portletName, String queryString)
813                    throws Exception {
814    
815                    Boolean secure = null;
816                    Boolean copyCurrentRenderParameters = null;
817                    Boolean escapeXml = null;
818                    long referPlid = LayoutConstants.DEFAULT_PLID;
819                    Boolean anchor = null;
820                    Boolean encrypt = null;
821                    long doAsGroupId = 0;
822                    long doAsUserId = 0;
823                    Boolean portletConfiguration = null;
824    
825                    renderURL(
826                            windowState, portletMode, secure, copyCurrentRenderParameters,
827                            escapeXml, plid, referPlid, portletName, anchor, encrypt,
828                            doAsGroupId, doAsUserId, portletConfiguration, queryString);
829            }
830    
831            public void renderURL(
832                            String windowState, String portletMode, String portletName,
833                            String queryString)
834                    throws Exception {
835    
836                    renderURL(
837                            windowState, portletMode, LayoutConstants.DEFAULT_PLID, portletName,
838                            queryString);
839            }
840    
841            public void runtime(String portletName) throws Exception {
842                    runtime(portletName, null);
843            }
844    
845            public void runtime(String portletName, String queryString)
846                    throws Exception {
847    
848                    RuntimeTag.doTag(portletName, queryString, null, _request, _response);
849            }
850    
851            public void runtime(
852                            String portletName, String queryString, String defaultPreferences)
853                    throws Exception {
854    
855                    RuntimeTag.doTag(
856                            portletName, queryString, defaultPreferences, null, _request,
857                            _response);
858            }
859    
860            public void search() throws Exception {
861                    SearchTag searchTag = new SearchTag();
862    
863                    setUp(searchTag);
864    
865                    searchTag.runTag();
866            }
867    
868            public void setTemplateContext(TemplateContext templateContext) {
869                    _templateContext = templateContext;
870            }
871    
872            public void sitesDirectory() throws Exception {
873                    SitesDirectoryTag sitesDirectoryTag = new SitesDirectoryTag();
874    
875                    setUp(sitesDirectoryTag);
876    
877                    sitesDirectoryTag.runTag();
878            }
879    
880            public void sitesDirectory(String displayStyle, String sites)
881                    throws Exception {
882    
883                    SitesDirectoryTag sitesDirectoryTag = new SitesDirectoryTag();
884    
885                    setUp(sitesDirectoryTag);
886    
887                    sitesDirectoryTag.setDisplayStyle(displayStyle);
888                    sitesDirectoryTag.setSites(sites);
889    
890                    sitesDirectoryTag.runTag();
891            }
892    
893            public void socialBookmarks(
894                            String displayStyle, String target, String types, String title,
895                            String url)
896                    throws Exception {
897    
898                    SocialBookmarksTag socialBookmarksTag = new SocialBookmarksTag();
899    
900                    setUp(socialBookmarksTag);
901    
902                    socialBookmarksTag.setDisplayStyle(displayStyle);
903                    socialBookmarksTag.setTarget(target);
904                    socialBookmarksTag.setTypes(types);
905                    socialBookmarksTag.setTitle(title);
906                    socialBookmarksTag.setUrl(url);
907    
908                    socialBookmarksTag.runTag();
909            }
910    
911            public void staging() throws Exception {
912                    StagingTag stagingTag = new StagingTag();
913    
914                    setUp(stagingTag);
915    
916                    stagingTag.runTag();
917            }
918    
919            public void toggle(
920                            String id, String showImage, String hideImage, String showMessage,
921                            String hideMessage, boolean defaultShowContent)
922                    throws Exception {
923    
924                    ToggleTag.doTag(
925                            id, showImage, hideImage, showMessage, hideMessage,
926                            defaultShowContent, null, _servletContext, _request, _response);
927            }
928    
929            public String wrapPortlet(String wrapPage, String portletPage)
930                    throws Exception {
931    
932                    return WrapPortletTag.doTag(
933                            wrapPage, portletPage, _servletContext, _request, _response,
934                            _pageContext);
935            }
936    
937            protected VelocityTaglibImpl init(
938                    ServletContext servletContext, HttpServletRequest request,
939                    HttpServletResponse response, PageContext pageContext,
940                    TemplateContext templateContext) {
941    
942                    _servletContext = servletContext;
943                    _request = request;
944                    _response = response;
945                    _pageContext = pageContext;
946                    _templateContext = templateContext;
947    
948                    return this;
949            }
950    
951            protected void setUp(TagSupport tagSupport) throws Exception {
952                    Writer writer = null;
953    
954                    if (_templateContext != null) {
955                            writer = (Writer)_templateContext.get(TemplateContext.WRITER);
956                    }
957    
958                    if (writer == null) {
959                            writer = _response.getWriter();
960                    }
961    
962                    tagSupport.setPageContext(new PipingPageContext(_pageContext, writer));
963            }
964    
965            private PageContext _pageContext;
966            private HttpServletRequest _request;
967            private HttpServletResponse _response;
968            private ServletContext _servletContext;
969            private TemplateContext _templateContext;
970    
971    }