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