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