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