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