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