1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.job.Scheduler;
26  import com.liferay.portal.kernel.log.Log;
27  import com.liferay.portal.kernel.log.LogFactoryUtil;
28  import com.liferay.portal.kernel.plugin.PluginPackage;
29  import com.liferay.portal.kernel.poller.PollerProcessor;
30  import com.liferay.portal.kernel.pop.MessageListener;
31  import com.liferay.portal.kernel.portlet.ConfigurationAction;
32  import com.liferay.portal.kernel.portlet.FriendlyURLMapper;
33  import com.liferay.portal.kernel.portlet.PortletBag;
34  import com.liferay.portal.kernel.portlet.PortletBagPool;
35  import com.liferay.portal.kernel.portlet.PortletLayoutListener;
36  import com.liferay.portal.kernel.search.Indexer;
37  import com.liferay.portal.kernel.search.OpenSearch;
38  import com.liferay.portal.kernel.servlet.URLEncoder;
39  import com.liferay.portal.kernel.util.ContentTypes;
40  import com.liferay.portal.kernel.util.InstancePool;
41  import com.liferay.portal.kernel.util.StringPool;
42  import com.liferay.portal.kernel.util.StringUtil;
43  import com.liferay.portal.kernel.util.Validator;
44  import com.liferay.portal.lar.PortletDataHandler;
45  import com.liferay.portal.model.Plugin;
46  import com.liferay.portal.model.PluginSetting;
47  import com.liferay.portal.model.Portlet;
48  import com.liferay.portal.model.PortletApp;
49  import com.liferay.portal.model.PortletConstants;
50  import com.liferay.portal.model.PortletFilter;
51  import com.liferay.portal.model.PortletInfo;
52  import com.liferay.portal.model.PublicRenderParameter;
53  import com.liferay.portal.model.RoleConstants;
54  import com.liferay.portal.model.User;
55  import com.liferay.portal.service.RoleLocalServiceUtil;
56  import com.liferay.portal.service.UserLocalServiceUtil;
57  import com.liferay.portal.util.PortalUtil;
58  import com.liferay.portal.util.PropsValues;
59  import com.liferay.portal.util.QNameUtil;
60  import com.liferay.portlet.PortletBagImpl;
61  import com.liferay.portlet.social.model.SocialActivityInterpreter;
62  import com.liferay.portlet.social.model.SocialRequestInterpreter;
63  
64  import java.util.ArrayList;
65  import java.util.Arrays;
66  import java.util.HashMap;
67  import java.util.HashSet;
68  import java.util.Hashtable;
69  import java.util.Iterator;
70  import java.util.LinkedHashMap;
71  import java.util.List;
72  import java.util.Map;
73  import java.util.Set;
74  import java.util.TreeSet;
75  
76  import javax.portlet.PortletMode;
77  import javax.portlet.WindowState;
78  
79  import javax.xml.namespace.QName;
80  
81  /**
82   * <a href="PortletImpl.java.html"><b><i>View Source</i></b></a>
83   *
84   * @author Brian Wing Shun Chan
85   */
86  public class PortletImpl extends PortletModelImpl implements Portlet {
87  
88      /**
89       * Constructs a portlet with no parameters.
90       */
91      public PortletImpl() {
92      }
93  
94      /**
95       * Constructs a portlet with the specified parameters.
96       */
97      public PortletImpl(long companyId, String portletId) {
98          setCompanyId(companyId);
99          setPortletId(portletId);
100         setStrutsPath(portletId);
101         setActive(true);
102         _headerPortalCss = new ArrayList<String>();
103         _headerPortletCss = new ArrayList<String>();
104         _headerPortalJavaScript = new ArrayList<String>();
105         _headerPortletJavaScript = new ArrayList<String>();
106         _footerPortalCss = new ArrayList<String>();
107         _footerPortletCss = new ArrayList<String>();
108         _footerPortalJavaScript = new ArrayList<String>();
109         _footerPortletJavaScript = new ArrayList<String>();
110         _unlinkedRoles = new HashSet<String>();
111         _roleMappers = new LinkedHashMap<String, String>();
112         _initParams = new HashMap<String, String>();
113         _portletModes = new HashMap<String, Set<String>>();
114         _windowStates = new HashMap<String, Set<String>>();
115         _supportedLocales = new HashSet<String>();
116         _portletFilters = new LinkedHashMap<String, PortletFilter>();
117         _processingEvents = new HashSet<QName>();
118         _publishingEvents = new HashSet<QName>();
119         _publicRenderParameters = new HashSet<PublicRenderParameter>();
120     }
121 
122     /**
123      * Constructs a portlet with the specified parameters.
124      */
125     public PortletImpl(
126         String portletId, PluginPackage pluginPackage,
127         PluginSetting pluginSetting, long companyId, long timestamp,
128         String icon, String virtualPath, String strutsPath, String portletName,
129         String displayName, String portletClass,
130         String configurationActionClass, String indexerClass,
131         String openSearchClass, String schedulerClass, String portletURLClass,
132         String friendlyURLMapperClass, String urlEncoderClass,
133         String portletDataHandlerClass, String portletLayoutListenerClass,
134         String pollerProcessorClass, String popMessageListenerClass,
135         String socialActivityInterpreterClass,
136         String socialRequestInterpreterClass, String defaultPreferences,
137         String prefsValidator, boolean prefsCompanyWide,
138         boolean prefsUniquePerLayout, boolean prefsOwnedByGroup,
139         boolean useDefaultTemplate, boolean showPortletAccessDenied,
140         boolean showPortletInactive, boolean actionURLRedirect,
141         boolean restoreCurrentView, boolean maximizeEdit, boolean maximizeHelp,
142         boolean popUpPrint, boolean layoutCacheable, boolean instanceable,
143         String userPrincipalStrategy, boolean privateRequestAttributes,
144         boolean privateSessionAttributes, int renderWeight, boolean ajaxable,
145         List<String> headerPortalCss, List<String> headerPortletCss,
146         List<String> headerPortalJavaScript,
147         List<String> headerPortletJavaScript, List<String> footerPortalCss,
148         List<String> footerPortletCss, List<String> footerPortalJavaScript,
149         List<String> footerPortletJavaScript,
150         String cssClassWrapper, String facebookIntegration,
151         boolean addDefaultResource, String roles, Set<String> unlinkedRoles,
152         Map<String, String> roleMappers, boolean system, boolean active,
153         boolean include, Map<String, String> initParams, Integer expCache,
154         Map<String, Set<String>> portletModes,
155         Map<String, Set<String>> windowStates, Set<String> supportedLocales,
156         String resourceBundle, PortletInfo portletInfo,
157         Map<String, PortletFilter> portletFilters, Set<QName> processingEvents,
158         Set<QName> publishingEvents,
159         Set<PublicRenderParameter> publicRenderParameters,
160         PortletApp portletApp) {
161 
162         setPortletId(portletId);
163         _pluginPackage = pluginPackage;
164         _defaultPluginSetting = pluginSetting;
165         setCompanyId(companyId);
166         _timestamp = timestamp;
167         _icon = icon;
168         _virtualPath = virtualPath;
169         _strutsPath = strutsPath;
170         _portletName = portletName;
171         _displayName = displayName;
172         _portletClass = portletClass;
173         _configurationActionClass = configurationActionClass;
174         _indexerClass = indexerClass;
175         _openSearchClass = openSearchClass;
176         _schedulerClass = schedulerClass;
177         _portletURLClass = portletURLClass;
178         _friendlyURLMapperClass = friendlyURLMapperClass;
179         _urlEncoderClass = urlEncoderClass;
180         _portletDataHandlerClass = portletDataHandlerClass;
181         _portletLayoutListenerClass = portletLayoutListenerClass;
182         _pollerProcessorClass = pollerProcessorClass;
183         _popMessageListenerClass = popMessageListenerClass;
184         _socialActivityInterpreterClass = socialActivityInterpreterClass;
185         _socialRequestInterpreterClass = socialRequestInterpreterClass;
186         _defaultPreferences = defaultPreferences;
187         _prefsValidator = prefsValidator;
188         _prefsCompanyWide = prefsCompanyWide;
189         _prefsUniquePerLayout = prefsUniquePerLayout;
190         _prefsOwnedByGroup = prefsOwnedByGroup;
191         _useDefaultTemplate = useDefaultTemplate;
192         _showPortletAccessDenied = showPortletAccessDenied;
193         _showPortletInactive = showPortletInactive;
194         _actionURLRedirect = actionURLRedirect;
195         _restoreCurrentView = restoreCurrentView;
196         _maximizeEdit = maximizeEdit;
197         _maximizeHelp = maximizeHelp;
198         _popUpPrint = popUpPrint;
199         _layoutCacheable = layoutCacheable;
200         _instanceable = instanceable;
201         _userPrincipalStrategy = userPrincipalStrategy;
202         _privateRequestAttributes = privateRequestAttributes;
203         _privateSessionAttributes = privateSessionAttributes;
204         _renderWeight = renderWeight;
205         _ajaxable = ajaxable;
206         _headerPortalCss = headerPortalCss;
207         _headerPortletCss = headerPortletCss;
208         _headerPortalJavaScript = headerPortalJavaScript;
209         _headerPortletJavaScript = headerPortletJavaScript;
210         _footerPortalCss = footerPortalCss;
211         _footerPortletCss = footerPortletCss;
212         _footerPortalJavaScript = footerPortalJavaScript;
213         _footerPortletJavaScript = footerPortletJavaScript;
214         _cssClassWrapper = cssClassWrapper;
215         _facebookIntegration = facebookIntegration;
216         _addDefaultResource = addDefaultResource;
217         setRoles(roles);
218         _unlinkedRoles = unlinkedRoles;
219         _roleMappers = roleMappers;
220         _system = system;
221         setActive(active);
222         _include = include;
223         _initParams = initParams;
224         _expCache = expCache;
225         _portletModes = portletModes;
226         _windowStates = windowStates;
227         _supportedLocales = supportedLocales;
228         _resourceBundle = resourceBundle;
229         _portletInfo = portletInfo;
230         _portletFilters = portletFilters;
231         setProcessingEvents(processingEvents);
232         setPublishingEvents(publishingEvents);
233         setPublicRenderParameters(publicRenderParameters);
234         _portletApp = portletApp;
235 
236         if (_instanceable) {
237             _clonedInstances = new Hashtable<String, Portlet>();
238         }
239     }
240 
241     /**
242      * Gets the root portlet id of the portlet.
243      *
244      * @return the root portlet id of the portlet
245      */
246     public String getRootPortletId() {
247         return PortletConstants.getRootPortletId(getPortletId());
248     }
249 
250     /**
251      * Gets the instance id of the portlet.
252      *
253      * @return the instance id of the portlet
254      */
255     public String getInstanceId() {
256         return PortletConstants.getInstanceId(getPortletId());
257     }
258 
259     /**
260      * Gets the plugin id of the portlet.
261      *
262      * @return the plugin id of the portlet
263      */
264     public String getPluginId() {
265         return getRootPortletId();
266     }
267 
268     /**
269      * Gets the plugin type of the portlet.
270      *
271      * @return the plugin type of the portlet
272      */
273     public String getPluginType() {
274         return Plugin.TYPE_PORTLET;
275     }
276 
277     /**
278      * Get the package to which the portlet belongs to.
279      *
280      * @return the plugin package of the portlet
281      */
282     public PluginPackage getPluginPackage() {
283         return _pluginPackage;
284     }
285 
286     /**
287      * Sets the plugin package this portlet belongs to.
288      *
289      * @param pluginPackage the plugin package
290      */
291     public void setPluginPackage(PluginPackage pluginPackage) {
292         _pluginPackage = pluginPackage;
293     }
294 
295     /**
296      * Get the default plugin settings of the portlet.
297      *
298      * @return the plugin settings
299      */
300     public PluginSetting getDefaultPluginSetting() {
301         return _defaultPluginSetting;
302     }
303 
304     /**
305      * Sets the default plugin settings of the portlet.
306      *
307      * @param pluginSetting the plugin setting
308      */
309     public void setDefaultPluginSetting(PluginSetting pluginSetting) {
310         _defaultPluginSetting = pluginSetting;
311     }
312 
313     /**
314      * Gets the timestamp of the portlet.
315      *
316      * @return the timestamp of the portlet
317      */
318     public long getTimestamp() {
319         return _timestamp;
320     }
321 
322     /**
323      * Sets the timestamp of the portlet.
324      *
325      * @param timestamp the timestamp of the portlet
326      */
327     public void setTimestamp(long timestamp) {
328         _timestamp = timestamp;
329     }
330 
331     /**
332      * Gets the icon of the portlet.
333      *
334      * @return the icon of the portlet
335      */
336     public String getIcon() {
337         return _icon;
338     }
339 
340     /**
341      * Sets the icon of the portlet.
342      *
343      * @param icon the icon of the portlet
344      */
345     public void setIcon(String icon) {
346         _icon = icon;
347     }
348 
349     /**
350      * Gets the virtual path of the portlet.
351      *
352      * @return the virtual path of the portlet
353      */
354     public String getVirtualPath() {
355         return _virtualPath;
356     }
357 
358     /**
359      * Sets the virtual path of the portlet.
360      *
361      * @param virtualPath the virtual path of the portlet
362      */
363     public void setVirtualPath(String virtualPath) {
364         if (_portletApp.isWARFile() && Validator.isNull(virtualPath)) {
365             virtualPath = PropsValues.PORTLET_VIRTUAL_PATH;
366         }
367 
368         _virtualPath = virtualPath;
369     }
370 
371     /**
372      * Gets the struts path of the portlet.
373      *
374      * @return the struts path of the portlet
375      */
376     public String getStrutsPath() {
377         return _strutsPath;
378     }
379 
380     /**
381      * Sets the struts path of the portlet.
382      *
383      * @param strutsPath the struts path of the portlet
384      */
385     public void setStrutsPath(String strutsPath) {
386         _strutsPath = strutsPath;
387     }
388 
389     /**
390      * Gets the name of the portlet.
391      *
392      * @return the display name of the portlet
393      */
394     public String getPortletName() {
395         return _portletName;
396     }
397 
398     /**
399      * Sets the name of the portlet.
400      *
401      * @param portletName the name of the portlet
402      */
403     public void setPortletName(String portletName) {
404         _portletName = portletName;
405     }
406 
407     /**
408      * Gets the display name of the portlet.
409      *
410      * @return the display name of the portlet
411      */
412     public String getDisplayName() {
413         return _displayName;
414     }
415 
416     /**
417      * Sets the display name of the portlet.
418      *
419      * @param displayName the display name of the portlet
420      */
421     public void setDisplayName(String displayName) {
422         _displayName = displayName;
423     }
424 
425     /**
426      * Gets the name of the portlet class of the portlet.
427      *
428      * @return the name of the portlet class of the portlet
429      */
430     public String getPortletClass() {
431         return _portletClass;
432     }
433 
434     /**
435      * Sets the name of the portlet class of the portlet.
436      *
437      * @param portletClass the name of the portlet class of the portlet
438      */
439     public void setPortletClass(String portletClass) {
440         _portletClass = portletClass;
441     }
442 
443     /**
444      * Gets the configuration action class of the portlet.
445      *
446      * @return the configuration action class of the portlet
447      */
448     public String getConfigurationActionClass() {
449         return _configurationActionClass;
450     }
451 
452     /**
453      * Sets the configuration action class of the portlet.
454      *
455      * @param configurationActionClass the configuration action class of the
456      *        portlet
457      */
458     public void setConfigurationActionClass(String configurationActionClass) {
459         _configurationActionClass = configurationActionClass;
460     }
461 
462     /**
463      * Gets the configuration action instance of the portlet.
464      *
465      * @return the configuration action instance of the portlet
466      */
467     public ConfigurationAction getConfigurationActionInstance() {
468         if (Validator.isNotNull(getConfigurationActionClass())) {
469             if (_portletApp.isWARFile()) {
470                 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
471 
472                 return portletBag.getConfigurationActionInstance();
473             }
474             else {
475                 return (ConfigurationAction)InstancePool.get(
476                     getConfigurationActionClass());
477             }
478         }
479 
480         return null;
481     }
482 
483     /**
484      * Gets the name of the indexer class of the portlet.
485      *
486      * @return the name of the indexer class of the portlet
487      */
488     public String getIndexerClass() {
489         return _indexerClass;
490     }
491 
492     /**
493      * Sets the name of the indexer class of the portlet.
494      *
495      * @param indexerClass the name of the indexer class of the portlet
496      */
497     public void setIndexerClass(String indexerClass) {
498         _indexerClass = indexerClass;
499     }
500 
501     /**
502      * Gets the indexer instance of the portlet.
503      *
504      * @return the indexer instance of the portlet
505      */
506     public Indexer getIndexerInstance() {
507         if (Validator.isNotNull(getIndexerClass())) {
508             if (_portletApp.isWARFile()) {
509                 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
510 
511                 return portletBag.getIndexerInstance();
512             }
513             else {
514                 return (Indexer)InstancePool.get(getIndexerClass());
515             }
516         }
517 
518         return null;
519     }
520 
521     /**
522      * Gets the name of the open search class of the portlet.
523      *
524      * @return the name of the open search class of the portlet
525      */
526     public String getOpenSearchClass() {
527         return _openSearchClass;
528     }
529 
530     /**
531      * Sets the name of the open search class of the portlet.
532      *
533      * @param openSearchClass the name of the open search class of the portlet
534      */
535     public void setOpenSearchClass(String openSearchClass) {
536         _openSearchClass = openSearchClass;
537     }
538 
539     /**
540      * Gets the indexer instance of the portlet.
541      *
542      * @return the indexer instance of the portlet
543      */
544     public OpenSearch getOpenSearchInstance() {
545         if (Validator.isNull(getOpenSearchClass())) {
546             return null;
547         }
548 
549         if (_portletApp.isWARFile()) {
550             PortletBag portletBag = PortletBagPool.get(getRootPortletId());
551 
552             return portletBag.getOpenSearchInstance();
553         }
554 
555         return (OpenSearch)InstancePool.get(getOpenSearchClass());
556     }
557 
558     /**
559      * Gets the name of the scheduler class of the portlet.
560      *
561      * @return the name of the scheduler class of the portlet
562      */
563     public String getSchedulerClass() {
564         return _schedulerClass;
565     }
566 
567     /**
568      * Sets the name of the scheduler class of the portlet.
569      *
570      * @param schedulerClass the name of the scheduler class of the portlet
571      */
572     public void setSchedulerClass(String schedulerClass) {
573         _schedulerClass = schedulerClass;
574     }
575 
576     /**
577      * Gets the scheduler instance of the portlet.
578      *
579      * @return the scheduler instance of the portlet
580      */
581     public Scheduler getSchedulerInstance() {
582         if (Validator.isNotNull(getSchedulerClass())) {
583             if (_portletApp.isWARFile()) {
584                 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
585 
586                 return portletBag.getSchedulerInstance();
587             }
588             else {
589                 return (Scheduler)InstancePool.get(getSchedulerClass());
590             }
591         }
592 
593         return null;
594     }
595 
596     /**
597      * Gets the name of the portlet URL class of the portlet.
598      *
599      * @return the name of the portlet URL class of the portlet
600      */
601     public String getPortletURLClass() {
602         return _portletURLClass;
603     }
604 
605     /**
606      * Sets the name of the portlet URL class of the portlet.
607      *
608      * @param portletURLClass the name of the portlet URL class of the portlet
609      */
610     public void setPortletURLClass(String portletURLClass) {
611         _portletURLClass = portletURLClass;
612     }
613 
614     /**
615      * Gets the name of the friendly URL mapper class of the portlet.
616      *
617      * @return the name of the friendly URL mapper class of the portlet
618      */
619     public String getFriendlyURLMapperClass() {
620         return _friendlyURLMapperClass;
621     }
622 
623     /**
624      * Sets the name of the friendly URL mapper class of the portlet.
625      *
626      * @param friendlyURLMapperClass the name of the friendly URL plugin class
627      *        of the portlet
628      */
629     public void setFriendlyURLMapperClass(String friendlyURLMapperClass) {
630         _friendlyURLMapperClass = friendlyURLMapperClass;
631     }
632 
633     /**
634      * Gets the friendly URL mapper instance of the portlet.
635      *
636      * @return the friendly URL mapper instance of the portlet
637      */
638     public FriendlyURLMapper getFriendlyURLMapperInstance() {
639         if (Validator.isNotNull(getFriendlyURLMapperClass())) {
640             if (_portletApp.isWARFile()) {
641                 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
642 
643                 return portletBag.getFriendlyURLMapperInstance();
644             }
645             else {
646                 return (FriendlyURLMapper)InstancePool.get(
647                     getFriendlyURLMapperClass());
648             }
649         }
650 
651         return null;
652     }
653 
654     /**
655      * Gets the name of the URL encoder class of the portlet.
656      *
657      * @return the name of the URL encoder class of the portlet
658      */
659     public String getURLEncoderClass() {
660         return _urlEncoderClass;
661     }
662 
663     /**
664      * Sets the name of the URL encoder class of the portlet.
665      *
666      * @param urlEncoderClass the name of the URL encoder class of the portlet
667      */
668     public void setURLEncoderClass(String urlEncoderClass) {
669         _urlEncoderClass = urlEncoderClass;
670     }
671 
672     /**
673      * Gets the URL encoder instance of the portlet.
674      *
675      * @return the URL encoder instance of the portlet
676      */
677     public URLEncoder getURLEncoderInstance() {
678         if (Validator.isNotNull(getURLEncoderClass())) {
679             if (_portletApp.isWARFile()) {
680                 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
681 
682                 return portletBag.getURLEncoderInstance();
683             }
684             else {
685                 return (URLEncoder)InstancePool.get(getURLEncoderClass());
686             }
687         }
688 
689         return null;
690     }
691 
692     /**
693      * Gets the name of the portlet data handler class of the portlet.
694      *
695      * @return the name of the portlet data handler class of the portlet
696      */
697     public String getPortletDataHandlerClass() {
698         return _portletDataHandlerClass;
699     }
700 
701     /**
702      * Sets the name of the portlet data handler class of the portlet.
703      *
704      * @param portletDataHandlerClass the name of portlet data handler class of
705      *        the portlet
706      */
707     public void setPortletDataHandlerClass(String portletDataHandlerClass) {
708         _portletDataHandlerClass = portletDataHandlerClass;
709     }
710 
711     /**
712      * Gets the portlet data handler instance of the portlet.
713      *
714      * @return the portlet data handler instance of the portlet
715      */
716     public PortletDataHandler getPortletDataHandlerInstance() {
717         if (Validator.isNotNull(getPortletDataHandlerClass())) {
718             if (_portletApp.isWARFile()) {
719                 PortletBagImpl portletBagImpl =
720                     (PortletBagImpl)PortletBagPool.get(getRootPortletId());
721 
722                 return portletBagImpl.getPortletDataHandlerInstance();
723             }
724             else {
725                 return (PortletDataHandler)InstancePool.get(
726                     getPortletDataHandlerClass());
727             }
728         }
729 
730         return null;
731     }
732 
733     /**
734      * Gets the portlet layout listener of the portlet.
735      *
736      * @return the name of the portlet layout listener class of the portlet
737      */
738     public PortletLayoutListener getPortletLayoutListener() {
739         if (Validator.isNull(getPortletLayoutListenerClass())) {
740             return null;
741         }
742 
743         return (PortletLayoutListener)InstancePool.get(
744             getPortletLayoutListenerClass());
745     }
746 
747     /**
748      * Gets the name of the portlet layout listener class of the portlet.
749      *
750      * @return the name of the portlet layout listener class of the portlet
751      */
752     public String getPortletLayoutListenerClass() {
753         return _portletLayoutListenerClass;
754     }
755 
756     /**
757      * Sets the name of the portlet layout listener class of the portlet.
758      *
759      * @param portletLayoutListenerClass the name of the portlet layout listener
760      *        class of the portlet
761      */
762     public void setPortletLayoutListenerClass(
763         String portletLayoutListenerClass) {
764 
765         _portletLayoutListenerClass = portletLayoutListenerClass;
766     }
767 
768     /**
769      * Gets the portlet layout listener instance of the portlet.
770      *
771      * @return the portlet layout listener instance of the portlet
772      */
773     public PortletLayoutListener getPortletLayoutListenerInstance() {
774         if (Validator.isNull(getPortletLayoutListenerClass())) {
775             return null;
776         }
777 
778         if (_portletApp.isWARFile()) {
779             PortletBag portletBag = PortletBagPool.get(getRootPortletId());
780 
781             return portletBag.getPortletLayoutListenerInstance();
782         }
783 
784         return (PortletLayoutListener)InstancePool.get(
785             getPortletLayoutListenerClass());
786     }
787 
788     /**
789      * Gets the name of the poller processor class of the portlet.
790      *
791      * @return the name of the poller processor class of the portlet
792      */
793     public String getPollerProcessorClass() {
794         return _pollerProcessorClass;
795     }
796 
797     /**
798      * Sets the name of the poller processor class of the portlet.
799      *
800      * @param pollerProcessorClass the name of the poller processor class of the
801      *        portlet
802      */
803     public void setPollerProcessorClass(String pollerProcessorClass) {
804         _pollerProcessorClass = pollerProcessorClass;
805     }
806 
807     /**
808      * Gets the poller processor instance of the portlet.
809      *
810      * @return the poller processor instance of the portlet
811      */
812     public PollerProcessor getPollerProcessorInstance() {
813         if (Validator.isNull(getPollerProcessorClass())) {
814             return null;
815         }
816 
817         if (_portletApp.isWARFile()) {
818             PortletBag portletBag = PortletBagPool.get(getRootPortletId());
819 
820             return portletBag.getPollerProcessorInstance();
821         }
822 
823         return (PollerProcessor)InstancePool.get(getPollerProcessorClass());
824     }
825 
826     /**
827      * Gets the name of the POP message listener class of the portlet.
828      *
829      * @return the name of the POP message listener class of the portlet
830      */
831     public String getPopMessageListenerClass() {
832         return _popMessageListenerClass;
833     }
834 
835     /**
836      * Sets the name of the POP message listener class of the portlet.
837      *
838      * @param popMessageListenerClass the name of the POP message listener class
839      *        of the portlet
840      */
841     public void setPopMessageListenerClass(String popMessageListenerClass) {
842         _popMessageListenerClass = popMessageListenerClass;
843     }
844 
845     /**
846      * Gets the POP message listener instance of the portlet.
847      *
848      * @return the POP message listener instance of the portlet
849      */
850     public MessageListener getPopMessageListenerInstance() {
851         if (Validator.isNotNull(getPopMessageListenerClass())) {
852             if (_portletApp.isWARFile()) {
853                 PortletBag portletBag = PortletBagPool.get(getRootPortletId());
854 
855                 return portletBag.getPopMessageListenerInstance();
856             }
857             else {
858                 return (MessageListener)InstancePool.get(
859                     getPopMessageListenerClass());
860             }
861         }
862 
863         return null;
864     }
865 
866     /**
867      * Gets the name of the social activity interpreter class of the portlet.
868      *
869      * @return the name of the social activity interpreter class of the
870      *         portlet
871      */
872     public String getSocialActivityInterpreterClass() {
873         return _socialActivityInterpreterClass;
874     }
875 
876     /**
877      * Sets the name of the social activity interpreter class of the portlet.
878      *
879      * @param socialActivityInterpreterClass the name of the activity
880      *        interpreter class of the portlet
881      */
882     public void setSocialActivityInterpreterClass(
883         String socialActivityInterpreterClass) {
884 
885         _socialActivityInterpreterClass = socialActivityInterpreterClass;
886     }
887 
888     /**
889      * Gets the name of the social activity interpreter instance of the portlet.
890      *
891      * @return the name of the social activity interpreter instance of the
892      *         portlet
893      */
894     public SocialActivityInterpreter getSocialActivityInterpreterInstance() {
895         if (Validator.isNotNull(getSocialActivityInterpreterClass())) {
896             if (_portletApp.isWARFile()) {
897                 PortletBagImpl portletBagImpl =
898                     (PortletBagImpl)PortletBagPool.get(getRootPortletId());
899 
900                 return portletBagImpl.getSocialActivityInterpreterInstance();
901             }
902             else {
903                 return (SocialActivityInterpreter)InstancePool.get(
904                     getSocialActivityInterpreterClass());
905             }
906         }
907 
908         return null;
909     }
910 
911     /**
912      * Gets the name of the social request interpreter class of the portlet.
913      *
914      * @return the name of the social request interpreter class of the
915      *         portlet
916      */
917     public String getSocialRequestInterpreterClass() {
918         return _socialRequestInterpreterClass;
919     }
920 
921     /**
922      * Sets the name of the social request interpreter class of the portlet.
923      *
924      * @param socialRequestInterpreterClass the name of the request interpreter
925      *        class of the portlet
926      */
927     public void setSocialRequestInterpreterClass(
928         String socialRequestInterpreterClass) {
929 
930         _socialRequestInterpreterClass = socialRequestInterpreterClass;
931     }
932 
933     /**
934      * Gets the name of the social request interpreter instance of the portlet.
935      *
936      * @return the name of the social request interpreter instance of the
937      *         portlet
938      */
939     public SocialRequestInterpreter getSocialRequestInterpreterInstance() {
940         if (Validator.isNotNull(getSocialRequestInterpreterClass())) {
941             if (_portletApp.isWARFile()) {
942                 PortletBagImpl portletBag =
943                     (PortletBagImpl)PortletBagPool.get(getRootPortletId());
944 
945                 return portletBag.getSocialRequestInterpreterInstance();
946             }
947             else {
948                 return (SocialRequestInterpreter)InstancePool.get(
949                     getSocialRequestInterpreterClass());
950             }
951         }
952 
953         return null;
954     }
955 
956     /**
957      * Gets the default preferences of the portlet.
958      *
959      * @return the default preferences of the portlet
960      */
961     public String getDefaultPreferences() {
962         if (Validator.isNull(_defaultPreferences)) {
963             return PortletConstants.DEFAULT_PREFERENCES;
964         }
965         else {
966             return _defaultPreferences;
967         }
968     }
969 
970     /**
971      * Sets the default preferences of the portlet.
972      *
973      * @param defaultPreferences the default preferences of the portlet
974      */
975     public void setDefaultPreferences(String defaultPreferences) {
976         _defaultPreferences = defaultPreferences;
977     }
978 
979     /**
980      * Gets the name of the preferences validator class of the portlet.
981      *
982      * @return the name of the preferences validator class of the portlet
983      */
984     public String getPreferencesValidator() {
985         return _prefsValidator;
986     }
987 
988     /**
989      * Sets the name of the preferences validator class of the portlet.
990      *
991      * @param prefsValidator the name of the preferences validator class of the
992      *        portlet
993      */
994     public void setPreferencesValidator(String prefsValidator) {
995         if (prefsValidator != null) {
996 
997             // Trim this because XDoclet generates preferences validators with
998             // extra white spaces
999 
1000            _prefsValidator = prefsValidator.trim();
1001        }
1002        else {
1003            _prefsValidator = null;
1004        }
1005    }
1006
1007    /**
1008     * Returns true if preferences are shared across the entire company.
1009     *
1010     * @return true if preferences are shared across the entire company
1011     */
1012    public boolean getPreferencesCompanyWide() {
1013        return _prefsCompanyWide;
1014    }
1015
1016    /**
1017     * Returns true if preferences are shared across the entire company.
1018     *
1019     * @return true if preferences are shared across the entire company
1020     */
1021    public boolean isPreferencesCompanyWide() {
1022        return _prefsCompanyWide;
1023    }
1024
1025    /**
1026     * Sets to true if preferences are shared across the entire company.
1027     *
1028     * @param prefsCompanyWide boolean value for whether preferences are shared
1029     *        across the entire company
1030     */
1031    public void setPreferencesCompanyWide(boolean prefsCompanyWide) {
1032        _prefsCompanyWide = prefsCompanyWide;
1033    }
1034
1035    /**
1036     * Returns true if preferences are unique per layout.
1037     *
1038     * @return true if preferences are unique per layout
1039     */
1040    public boolean getPreferencesUniquePerLayout() {
1041        return _prefsUniquePerLayout;
1042    }
1043
1044    /**
1045     * Returns true if preferences are unique per layout.
1046     *
1047     * @return true if preferences are unique per layout
1048     */
1049    public boolean isPreferencesUniquePerLayout() {
1050        return _prefsUniquePerLayout;
1051    }
1052
1053    /**
1054     * Sets to true if preferences are unique per layout.
1055     *
1056     * @param prefsUniquePerLayout boolean value for whether preferences are
1057     *        unique per layout
1058     */
1059    public void setPreferencesUniquePerLayout(boolean prefsUniquePerLayout) {
1060        _prefsUniquePerLayout = prefsUniquePerLayout;
1061    }
1062
1063    /**
1064     * Returns true if preferences are owned by the group when the portlet is
1065     * shown in a group layout. Returns false if preferences are owned by the
1066     * user at all times.
1067     *
1068     * @return true if preferences are owned by the group when the portlet
1069     *         is shown in a group layout; false if preferences are owned
1070     *         by the user at all times.
1071     */
1072    public boolean getPreferencesOwnedByGroup() {
1073        return _prefsOwnedByGroup;
1074    }
1075
1076    /**
1077     * Returns true if preferences are owned by the group when the portlet is
1078     * shown in a group layout. Returns false if preferences are owned by the
1079     * user at all times.
1080     *
1081     * @return true if preferences are owned by the group when the portlet
1082     *         is shown in a group layout; false if preferences are owned
1083     *         by the user at all times.
1084     */
1085    public boolean isPreferencesOwnedByGroup() {
1086        return _prefsOwnedByGroup;
1087    }
1088
1089    /**
1090     * Sets to true if preferences are owned by the group when the portlet is
1091     * shown in a group layout. Sets to false if preferences are owned by the
1092     * user at all times.
1093     *
1094     * @param prefsOwnedByGroup boolean value for whether preferences are owned
1095     *        by the group when the portlet is shown in a group layout or
1096     *        preferences are owned by the user at all times
1097     */
1098    public void setPreferencesOwnedByGroup(boolean prefsOwnedByGroup) {
1099        _prefsOwnedByGroup = prefsOwnedByGroup;
1100    }
1101
1102    /**
1103     * Returns true if the portlet uses the default template.
1104     *
1105     * @return true if the portlet uses the default template
1106     */
1107    public boolean getUseDefaultTemplate() {
1108        return _useDefaultTemplate;
1109    }
1110
1111    /**
1112     * Returns true if the portlet uses the default template.
1113     *
1114     * @return true if the portlet uses the default template
1115     */
1116    public boolean isUseDefaultTemplate() {
1117        return _useDefaultTemplate;
1118    }
1119
1120    /**
1121     * Sets to true if the portlet uses the default template.
1122     *
1123     * @param useDefaultTemplate boolean value for whether the portlet uses the
1124     *        default template
1125     */
1126    public void setUseDefaultTemplate(boolean useDefaultTemplate) {
1127        _useDefaultTemplate = useDefaultTemplate;
1128    }
1129
1130    /**
1131     * Returns true if users are shown that they do not have access to the
1132     * portlet.
1133     *
1134     * @return true if users are shown that they do not have access to the
1135     *         portlet
1136     */
1137    public boolean getShowPortletAccessDenied() {
1138        return _showPortletAccessDenied;
1139    }
1140
1141    /**
1142     * Returns true if users are shown that they do not have access to the
1143     * portlet.
1144     *
1145     * @return true if users are shown that they do not have access to the
1146     *         portlet
1147     */
1148    public boolean isShowPortletAccessDenied() {
1149        return _showPortletAccessDenied;
1150    }
1151
1152    /**
1153     * Sets to true if users are shown that they do not have access to the
1154     * portlet.
1155     *
1156     * @param showPortletAccessDenied boolean value for whether users are shown
1157     *        that they do not have access to the portlet
1158     */
1159    public void setShowPortletAccessDenied(boolean showPortletAccessDenied) {
1160        _showPortletAccessDenied = showPortletAccessDenied;
1161    }
1162
1163    /**
1164     * Returns true if users are shown that the portlet is inactive.
1165     *
1166     * @return true if users are shown that the portlet is inactive
1167     */
1168    public boolean getShowPortletInactive() {
1169        return _showPortletInactive;
1170    }
1171
1172    /**
1173     * Returns true if users are shown that the portlet is inactive.
1174     *
1175     * @return true if users are shown that the portlet is inactive
1176     */
1177    public boolean isShowPortletInactive() {
1178        return _showPortletInactive;
1179    }
1180
1181    /**
1182     * Sets to true if users are shown that the portlet is inactive.
1183     *
1184     * @param showPortletInactive boolean value for whether users are shown that
1185     *        the portlet is inactive
1186     */
1187    public void setShowPortletInactive(boolean showPortletInactive) {
1188        _showPortletInactive = showPortletInactive;
1189    }
1190
1191    /**
1192     * Returns true if an action URL for this portlet should cause an auto
1193     * redirect.
1194     *
1195     * @return true if an action URL for this portlet should cause an auto
1196     *         redirect
1197     */
1198    public boolean getActionURLRedirect() {
1199        return _actionURLRedirect;
1200    }
1201
1202    /**
1203     * Returns true if an action URL for this portlet should cause an auto
1204     * redirect.
1205     *
1206     * @return true if an action URL for this portlet should cause an auto
1207     *         redirect
1208     */
1209    public boolean isActionURLRedirect() {
1210        return _actionURLRedirect;
1211    }
1212
1213    /**
1214     * Sets to true if an action URL for this portlet should cause an auto
1215     * redirect.
1216     *
1217     * @param actionURLRedirect boolean value for whether an action URL for this
1218     *        portlet should cause an auto redirect
1219     */
1220    public void setActionURLRedirect(boolean actionURLRedirect) {
1221        _actionURLRedirect = actionURLRedirect;
1222    }
1223
1224    /**
1225     * Returns true if the portlet restores to the current view from the
1226     * maximized state.
1227     *
1228     * @return true if the portlet restores to the current view from the
1229     *         maximized state
1230     */
1231    public boolean getRestoreCurrentView() {
1232        return _restoreCurrentView;
1233    }
1234
1235    /**
1236     * Returns true if the portlet restores to the current view from the
1237     * maximized state.
1238     *
1239     * @return true if the portlet restores to the current view from the
1240     *         maximized state
1241     */
1242    public boolean isRestoreCurrentView() {
1243        return _restoreCurrentView;
1244    }
1245
1246    /**
1247     * Sets to true if the portlet restores to the current view from the
1248     * maximized state.
1249     *
1250     * @param restoreCurrentView boolean value for whether the portlet restores
1251     *        to the current view from the maximized state
1252     */
1253    public void setRestoreCurrentView(boolean restoreCurrentView) {
1254        _restoreCurrentView = restoreCurrentView;
1255    }
1256
1257    /**
1258     * Returns true if the portlet goes into the maximized state when the user
1259     * goes into the edit mode.
1260     *
1261     * @return true if the portlet goes into the maximized state when the
1262     *         user goes into the edit mode
1263     */
1264    public boolean getMaximizeEdit() {
1265        return _maximizeEdit;
1266    }
1267
1268    /**
1269     * Returns true if the portlet goes into the maximized state when the user
1270     * goes into the edit mode.
1271     *
1272     * @return true if the portlet goes into the maximized state when the
1273     *         user goes into the edit mode
1274     */
1275    public boolean isMaximizeEdit() {
1276        return _maximizeEdit;
1277    }
1278
1279    /**
1280     * Sets to true if the portlet goes into the maximized state when the user
1281     * goes into the edit mode.
1282     *
1283     * @param maximizeEdit boolean value for whether the portlet goes into the
1284     *        maximized state when the user goes into the edit mode
1285     */
1286    public void setMaximizeEdit(boolean maximizeEdit) {
1287        _maximizeEdit = maximizeEdit;
1288    }
1289
1290    /**
1291     * Returns true if the portlet goes into the maximized state when the user
1292     * goes into the help mode.
1293     *
1294     * @return true if the portlet goes into the maximized state when the
1295     *         user goes into the help mode
1296     */
1297    public boolean getMaximizeHelp() {
1298        return _maximizeHelp;
1299    }
1300
1301    /**
1302     * Returns true if the portlet goes into the maximized state when the user
1303     * goes into the help mode.
1304     *
1305     * @return true if the portlet goes into the maximized state when the
1306     *         user goes into the help mode
1307     */
1308    public boolean isMaximizeHelp() {
1309        return _maximizeHelp;
1310    }
1311
1312    /**
1313     * Sets to true if the portlet goes into the maximized state when the user
1314     * goes into the help mode.
1315     *
1316     * @param maximizeHelp boolean value for whether the portlet goes into the
1317     *        maximized state when the user goes into the help mode
1318     */
1319    public void setMaximizeHelp(boolean maximizeHelp) {
1320        _maximizeHelp = maximizeHelp;
1321    }
1322
1323    /**
1324     * Returns true if the portlet goes into the pop up state when the user goes
1325     * into the print mode.
1326     *
1327     * @return true if the portlet goes into the pop up state when the user
1328     *         goes into the print mode
1329     */
1330    public boolean getPopUpPrint() {
1331        return _popUpPrint;
1332    }
1333
1334    /**
1335     * Returns true if the portlet goes into the pop up state when the user goes
1336     * into the print mode.
1337     *
1338     * @return true if the portlet goes into the pop up state when the user
1339     *         goes into the print mode
1340     */
1341    public boolean isPopUpPrint() {
1342        return _popUpPrint;
1343    }
1344
1345    /**
1346     * Sets to true if the portlet goes into the pop up state when the user goes
1347     * into the print mode.
1348     *
1349     * @param popUpPrint boolean value for whether the portlet goes into the pop
1350     *        up state when the user goes into the print mode
1351     */
1352    public void setPopUpPrint(boolean popUpPrint) {
1353        _popUpPrint = popUpPrint;
1354    }
1355
1356    /**
1357     * Returns true to allow the portlet to be cached within the layout.
1358     *
1359     * @return true if the portlet can be cached within the layout
1360     */
1361    public boolean getLayoutCacheable() {
1362        return _layoutCacheable;
1363    }
1364
1365    /**
1366     * Returns true to allow the portlet to be cached within the layout.
1367     *
1368     * @return true if the portlet can be cached within the layout
1369     */
1370    public boolean isLayoutCacheable() {
1371        return _layoutCacheable;
1372    }
1373
1374    /**
1375     * Sets to true to allow the portlet to be cached within the layout.
1376     *
1377     * @param layoutCacheable boolean value for whether the portlet can be
1378     *        cached within the layout
1379     */
1380    public void setLayoutCacheable(boolean layoutCacheable) {
1381        _layoutCacheable = layoutCacheable;
1382    }
1383
1384    /**
1385     * Returns true if the portlet can be added multiple times to a layout.
1386     *
1387     * @return true if the portlet can be added multiple times to a layout
1388     */
1389    public boolean getInstanceable() {
1390        return _instanceable;
1391    }
1392
1393    /**
1394     * Returns true if the portlet can be added multiple times to a layout.
1395     *
1396     * @return true if the portlet can be added multiple times to a layout
1397     */
1398    public boolean isInstanceable() {
1399        return _instanceable;
1400    }
1401
1402    /**
1403     * Sets to true if the portlet can be added multiple times to a layout.
1404     *
1405     * @param instanceable boolean value for whether the portlet can be added
1406     *        multiple times to a layout
1407     */
1408    public void setInstanceable(boolean instanceable) {
1409        _instanceable = instanceable;
1410    }
1411
1412    /**
1413     * Gets the user principal strategy of the portlet.
1414     *
1415     * @return the user principal strategy of the portlet
1416     */
1417    public String getUserPrincipalStrategy() {
1418        return _userPrincipalStrategy;
1419    }
1420
1421    /**
1422     * Sets the user principal strategy of the portlet.
1423     *
1424     * @param userPrincipalStrategy the user principal strategy of the portlet
1425     */
1426    public void setUserPrincipalStrategy(String userPrincipalStrategy) {
1427        if (Validator.isNotNull(userPrincipalStrategy)) {
1428            _userPrincipalStrategy = userPrincipalStrategy;
1429        }
1430    }
1431
1432    /**
1433     * Returns true if the portlet does not share request attributes with the
1434     * portal or portlets from another WAR.
1435     *
1436     * @return true if the portlet does not share request attributes with
1437     *         the portal or portlets from another WAR
1438     */
1439    public boolean getPrivateRequestAttributes() {
1440        return _privateRequestAttributes;
1441    }
1442
1443    /**
1444     * Returns true if the portlet does not share request attributes with the
1445     * portal or portlets from another WAR.
1446     *
1447     * @return true if the portlet does not share request attributes with
1448     *         the portal or portlets from another WAR
1449     */
1450    public boolean isPrivateRequestAttributes() {
1451        return _privateRequestAttributes;
1452    }
1453
1454    /**
1455     * Sets to true if the portlet does not share request attributes with the
1456     * portal or portlets from another WAR.
1457     *
1458     * @param privateRequestAttributes boolean value for whether the portlet
1459     *        shares request attributes with the portal or portlets from another
1460     *        WAR
1461     */
1462    public void setPrivateRequestAttributes(boolean privateRequestAttributes) {
1463        _privateRequestAttributes = privateRequestAttributes;
1464    }
1465
1466    /**
1467     * Returns true if the portlet does not share session attributes with the
1468     * portal.
1469     *
1470     * @return true if the portlet does not share session attributes with
1471     *         the portal
1472     */
1473    public boolean getPrivateSessionAttributes() {
1474        return _privateSessionAttributes;
1475    }
1476
1477    /**
1478     * Returns true if the portlet does not share session attributes with the
1479     * portal.
1480     *
1481     * @return true if the portlet does not share session attributes with
1482     *         the portal
1483     */
1484    public boolean isPrivateSessionAttributes() {
1485        return _privateSessionAttributes;
1486    }
1487
1488    /**
1489     * Sets to true if the portlet does not share session attributes with the
1490     * portal.
1491     *
1492     * @param privateSessionAttributes boolean value for whether the portlet
1493     *        shares session attributes with the portal
1494     */
1495    public void setPrivateSessionAttributes(boolean privateSessionAttributes) {
1496        _privateSessionAttributes = privateSessionAttributes;
1497    }
1498
1499    /**
1500     * Returns the render weight of the portlet.
1501     *
1502     * @return the render weight of the portlet
1503     */
1504    public int getRenderWeight() {
1505        return _renderWeight;
1506    }
1507
1508    /**
1509     * Sets the render weight of the portlet.
1510     *
1511     * @param renderWeight int value for the render weight of the portlet
1512     */
1513    public void setRenderWeight(int renderWeight) {
1514        _renderWeight = renderWeight;
1515    }
1516
1517    /**
1518     * Returns true if the portlet can be displayed via Ajax.
1519     *
1520     * @return true if the portlet can be displayed via Ajax
1521     */
1522    public boolean getAjaxable() {
1523        return _ajaxable;
1524    }
1525
1526    /**
1527     * Returns true if the portlet can be displayed via Ajax.
1528     *
1529     * @return true if the portlet can be displayed via Ajax
1530     */
1531    public boolean isAjaxable() {
1532        return _ajaxable;
1533    }
1534
1535    /**
1536     * Sets to true if the portlet can be displayed via Ajax.
1537     *
1538     * @param ajaxable boolean value for whether the portlet can be displayed
1539     *        via Ajax
1540     */
1541    public void setAjaxable(boolean ajaxable) {
1542        _ajaxable = ajaxable;
1543    }
1544
1545    /**
1546     * Gets a list of CSS files that will be referenced from the page's header
1547     * relative to the portal's context path.
1548     *
1549     * @return a list of CSS files that will be referenced from the page's
1550     *         header relative to the portal's context path
1551     */
1552    public List<String> getHeaderPortalCss() {
1553        return _headerPortalCss;
1554    }
1555
1556    /**
1557     * Sets a list of CSS files that will be referenced from the page's header
1558     * relative to the portal's context path.
1559     *
1560     * @param headerPortalCss a list of CSS files that will be referenced from
1561     *        the page's header relative to the portal's context path
1562     */
1563    public void setHeaderPortalCss(List<String> headerPortalCss) {
1564        _headerPortalCss = headerPortalCss;
1565    }
1566
1567    /**
1568     * Gets a list of CSS files that will be referenced from the page's header
1569     * relative to the portlet's context path.
1570     *
1571     * @return a list of CSS files that will be referenced from the page's
1572     *         header relative to the portlet's context path
1573     */
1574    public List<String> getHeaderPortletCss() {
1575        return _headerPortletCss;
1576    }
1577
1578    /**
1579     * Sets a list of CSS files that will be referenced from the page's header
1580     * relative to the portlet's context path.
1581     *
1582     * @param headerPortletCss a list of CSS files that will be referenced from
1583     *        the page's header relative to the portlet's context path
1584     */
1585    public void setHeaderPortletCss(List<String> headerPortletCss) {
1586        _headerPortletCss = headerPortletCss;
1587    }
1588
1589    /**
1590     * Gets a list of JavaScript files that will be referenced from the page's
1591     * header relative to the portal's context path.
1592     *
1593     * @return a list of JavaScript files that will be referenced from the
1594     *         page's header relative to the portal's context path
1595     */
1596    public List<String> getHeaderPortalJavaScript() {
1597        return _headerPortalJavaScript;
1598    }
1599
1600    /**
1601     * Sets a list of JavaScript files that will be referenced from the page's
1602     * header relative to the portal's context path.
1603     *
1604     * @param headerPortalJavaScript a list of JavaScript files that will be
1605     *        referenced from the page's header relative to the portal's context
1606     *        path
1607     */
1608    public void setHeaderPortalJavaScript(List<String> headerPortalJavaScript) {
1609        _headerPortalJavaScript = headerPortalJavaScript;
1610    }
1611
1612    /**
1613     * Gets a list of JavaScript files that will be referenced from the page's
1614     * header relative to the portlet's context path.
1615     *
1616     * @return a list of JavaScript files that will be referenced from the
1617     *         page's header relative to the portlet's context path
1618     */
1619    public List<String> getHeaderPortletJavaScript() {
1620        return _headerPortletJavaScript;
1621    }
1622
1623    /**
1624     * Sets a list of JavaScript files that will be referenced from the page's
1625     * header relative to the portlet's context path.
1626     *
1627     * @param headerPortletJavaScript a list of JavaScript files that will be
1628     *        referenced from the page's header relative to the portlet's
1629     *        context path
1630     */
1631    public void setHeaderPortletJavaScript(
1632        List<String> headerPortletJavaScript) {
1633
1634        _headerPortletJavaScript = headerPortletJavaScript;
1635    }
1636
1637    /**
1638     * Gets a list of CSS files that will be referenced from the page's footer
1639     * relative to the portal's context path.
1640     *
1641     * @return a list of CSS files that will be referenced from the page's
1642     *         footer relative to the portal's context path
1643     */
1644    public List<String> getFooterPortalCss() {
1645        return _footerPortalCss;
1646    }
1647
1648    /**
1649     * Sets a list of CSS files that will be referenced from the page's footer
1650     * relative to the portal's context path.
1651     *
1652     * @param footerPortalCss a list of CSS files that will be referenced from
1653     *        the page's footer relative to the portal's context path
1654     */
1655    public void setFooterPortalCss(List<String> footerPortalCss) {
1656        _footerPortalCss = footerPortalCss;
1657    }
1658
1659    /**
1660     * Gets a list of CSS files that will be referenced from the page's footer
1661     * relative to the portlet's context path.
1662     *
1663     * @return a list of CSS files that will be referenced from the page's
1664     *         footer relative to the portlet's context path
1665     */
1666    public List<String> getFooterPortletCss() {
1667        return _footerPortletCss;
1668    }
1669
1670    /**
1671     * Sets a list of CSS files that will be referenced from the page's footer
1672     * relative to the portlet's context path.
1673     *
1674     * @param footerPortletCss a list of CSS files that will be referenced from
1675     *        the page's footer relative to the portlet's context path
1676     */
1677    public void setFooterPortletCss(List<String> footerPortletCss) {
1678        _footerPortletCss = footerPortletCss;
1679    }
1680
1681    /**
1682     * Gets a list of JavaScript files that will be referenced from the page's
1683     * footer relative to the portal's context path.
1684     *
1685     * @return a list of JavaScript files that will be referenced from the
1686     *         page's footer relative to the portal's context path
1687     */
1688    public List<String> getFooterPortalJavaScript() {
1689        return _footerPortalJavaScript;
1690    }
1691
1692    /**
1693     * Sets a list of JavaScript files that will be referenced from the page's
1694     * footer relative to the portal's context path.
1695     *
1696     * @param footerPortalJavaScript a list of JavaScript files that will be
1697     *        referenced from the page's footer relative to the portal's context
1698     *        path
1699     */
1700    public void setFooterPortalJavaScript(List<String> footerPortalJavaScript) {
1701        _footerPortalJavaScript = footerPortalJavaScript;
1702    }
1703
1704    /**
1705     * Gets a list of JavaScript files that will be referenced from the page's
1706     * footer relative to the portlet's context path.
1707     *
1708     * @return a list of JavaScript files that will be referenced from the
1709     *         page's footer relative to the portlet's context path
1710     */
1711    public List<String> getFooterPortletJavaScript() {
1712        return _footerPortletJavaScript;
1713    }
1714
1715    /**
1716     * Sets a list of JavaScript files that will be referenced from the page's
1717     * footer relative to the portlet's context path.
1718     *
1719     * @param footerPortletJavaScript a list of JavaScript files that will be
1720     *        referenced from the page's footer relative to the portlet's
1721     *        context path
1722     */
1723    public void setFooterPortletJavaScript(
1724        List<String> footerPortletJavaScript) {
1725
1726        _footerPortletJavaScript = footerPortletJavaScript;
1727    }
1728
1729    /**
1730     * Gets the name of the CSS class that will be injected in the DIV that
1731     * wraps this portlet.
1732     *
1733     * @return the name of the CSS class that will be injected in the DIV
1734     *         that wraps this portlet
1735     */
1736    public String getCssClassWrapper() {
1737        return _cssClassWrapper;
1738    }
1739
1740    /**
1741     * Sets the name of the CSS class that will be injected in the DIV that
1742     * wraps this portlet.
1743     *
1744     * @param cssClassWrapper the name of the CSS class that will be injected in
1745     *        the DIV that wraps this portlet
1746     */
1747    public void setCssClassWrapper(String cssClassWrapper) {
1748        _cssClassWrapper = cssClassWrapper;
1749    }
1750
1751    /**
1752     * Gets the Facebook integration method of the portlet.
1753     *
1754     * @return the Facebook integration method of the portlet
1755     */
1756    public String getFacebookIntegration() {
1757        return _facebookIntegration;
1758    }
1759
1760    /**
1761     * Sets the Facebook integration method of the portlet.
1762     *
1763     * @param facebookIntegration the Facebook integration method of the portlet
1764     */
1765    public void setFacebookIntegration(String facebookIntegration) {
1766        if (Validator.isNotNull(facebookIntegration)) {
1767            _facebookIntegration = facebookIntegration;
1768        }
1769    }
1770
1771    /**
1772     * Returns true if default resources for the portlet are added to a page.
1773     *
1774     * @return true if default resources for the portlet are added to a
1775     *         page
1776     */
1777    public boolean getAddDefaultResource() {
1778        return _addDefaultResource;
1779    }
1780
1781    /**
1782     * Returns true if default resources for the portlet are added to a page.
1783     *
1784     * @return true if default resources for the portlet are added to a
1785     *         page
1786     */
1787    public boolean isAddDefaultResource() {
1788        return _addDefaultResource;
1789    }
1790
1791    /**
1792     * Sets to true if default resources for the portlet are added to a page.
1793     *
1794     * @param addDefaultResource boolean value for whether or not default
1795     *        resources for the portlet are added to a page
1796     */
1797    public void setAddDefaultResource(boolean addDefaultResource) {
1798        _addDefaultResource = addDefaultResource;
1799    }
1800
1801    /**
1802     * Sets a string of ordered comma delimited portlet ids.
1803     *
1804     * @param roles a string of ordered comma delimited portlet ids
1805     */
1806    public void setRoles(String roles) {
1807        _rolesArray = StringUtil.split(roles);
1808
1809        super.setRoles(roles);
1810    }
1811
1812    /**
1813     * Gets an array of required roles of the portlet.
1814     *
1815     * @return an array of required roles of the portlet
1816     */
1817    public String[] getRolesArray() {
1818        return _rolesArray;
1819    }
1820
1821    /**
1822     * Sets an array of required roles of the portlet.
1823     *
1824     * @param rolesArray an array of required roles of the portlet
1825     */
1826    public void setRolesArray(String[] rolesArray) {
1827        _rolesArray = rolesArray;
1828
1829        super.setRoles(StringUtil.merge(rolesArray));
1830    }
1831
1832    /**
1833     * Gets the unlinked roles of the portlet.
1834     *
1835     * @return unlinked roles of the portlet
1836     */
1837    public Set<String> getUnlinkedRoles() {
1838        return _unlinkedRoles;
1839    }
1840
1841    /**
1842     * Sets the unlinked roles of the portlet.
1843     *
1844     * @param unlinkedRoles the unlinked roles of the portlet
1845     */
1846    public void setUnlinkedRoles(Set<String> unlinkedRoles) {
1847        _unlinkedRoles = unlinkedRoles;
1848    }
1849
1850    /**
1851     * Gets the role mappers of the portlet.
1852     *
1853     * @return role mappers of the portlet
1854     */
1855    public Map<String, String> getRoleMappers() {
1856        return _roleMappers;
1857    }
1858
1859    /**
1860     * Sets the role mappers of the portlet.
1861     *
1862     * @param roleMappers the role mappers of the portlet
1863     */
1864    public void setRoleMappers(Map<String, String> roleMappers) {
1865        _roleMappers = roleMappers;
1866    }
1867
1868    /**
1869     * Link the role names set in portlet.xml with the Liferay roles set in
1870     * liferay-portlet.xml.
1871     */
1872    public void linkRoles() {
1873        List<String> linkedRoles = new ArrayList<String>();
1874
1875        Iterator<String> itr = _unlinkedRoles.iterator();
1876
1877        while (itr.hasNext()) {
1878            String unlinkedRole = itr.next();
1879
1880            String roleLink = _roleMappers.get(unlinkedRole);
1881
1882            if (Validator.isNotNull(roleLink)) {
1883                if (_log.isDebugEnabled()) {
1884                    _log.debug(
1885                        "Linking role for portlet [" + getPortletId() +
1886                            "] with role-name [" + unlinkedRole +
1887                                "] to role-link [" + roleLink + "]");
1888                }
1889
1890                linkedRoles.add(roleLink);
1891            }
1892            else {
1893                _log.error(
1894                    "Unable to link role for portlet [" + getPortletId() +
1895                        "] with role-name [" + unlinkedRole +
1896                            "] because role-link is null");
1897            }
1898        }
1899
1900        String[] array = linkedRoles.toArray(new String[linkedRoles.size()]);
1901
1902        Arrays.sort(array);
1903
1904        setRolesArray(array);
1905    }
1906
1907    /**
1908     * Returns true if the portlet has a role with the specified name.
1909     *
1910     * @return true if the portlet has a role with the specified name
1911     */
1912    public boolean hasRoleWithName(String roleName) {
1913        if ((_rolesArray == null) || (_rolesArray.length == 0)) {
1914            return false;
1915        }
1916
1917        for (int i = 0; i < _rolesArray.length; i++) {
1918            if (_rolesArray[i].equalsIgnoreCase(roleName)) {
1919                return true;
1920            }
1921        }
1922
1923        return false;
1924    }
1925
1926    /**
1927     * Returns true if the user has the permission to add the portlet to a
1928     * layout.
1929     *
1930     * @return true if the user has the permission to add the portlet to a
1931     *         layout
1932     */
1933    public boolean hasAddPortletPermission(long userId) {
1934        try {
1935            if ((_rolesArray == null) || (_rolesArray.length == 0)) {
1936                return true;
1937            }
1938            else if (RoleLocalServiceUtil.hasUserRoles(
1939                        userId, getCompanyId(), _rolesArray, true)) {
1940
1941                return true;
1942            }
1943            else if (RoleLocalServiceUtil.hasUserRole(
1944                        userId, getCompanyId(), RoleConstants.ADMINISTRATOR,
1945                        true)) {
1946
1947                return true;
1948            }
1949            else {
1950                User user = UserLocalServiceUtil.getUserById(userId);
1951
1952                if (user.isDefaultUser() &&
1953                    hasRoleWithName(RoleConstants.GUEST)) {
1954
1955                    return true;
1956                }
1957            }
1958        }
1959        catch (Exception e) {
1960            _log.error(e);
1961        }
1962
1963        return false;
1964    }
1965
1966    /**
1967     * Returns true if the portlet is a system portlet that a user cannot
1968     * manually add to their page.
1969     *
1970     * @return true if the portlet is a system portlet that a user cannot
1971     *         manually add to their page
1972     */
1973    public boolean getSystem() {
1974        return _system;
1975    }
1976
1977    /**
1978     * Returns true if the portlet is a system portlet that a user cannot
1979     * manually add to their page.
1980     *
1981     * @return true if the portlet is a system portlet that a user cannot
1982     *         manually add to their page
1983     */
1984    public boolean isSystem() {
1985        return _system;
1986    }
1987
1988    /**
1989     * Sets to true if the portlet is a system portlet that a user cannot
1990     * manually add to their page.
1991     *
1992     * @param system boolean value for whether the portlet is a system portlet
1993     *        that a user cannot manually add to their page
1994     */
1995    public void setSystem(boolean system) {
1996        _system = system;
1997    }
1998
1999    /**
2000     * Returns true to include the portlet and make it available to be made
2001     * active.
2002     *
2003     * @return true to include the portlet and make it available to be made
2004     *         active
2005     */
2006    public boolean getInclude() {
2007        return _include;
2008    }
2009
2010    /**
2011     * Returns true to include the portlet and make it available to be made
2012     * active.
2013     *
2014     * @return true to include the portlet and make it available to be made
2015     *         active
2016     */
2017    public boolean isInclude() {
2018        return _include;
2019    }
2020
2021    /**
2022     * Sets to true to include the portlet and make it available to be made
2023     * active.
2024     *
2025     * @param include boolean value for whether to include the portlet and make
2026     *        it available to be made active
2027     */
2028    public void setInclude(boolean include) {
2029        _include = include;
2030    }
2031
2032    /**
2033     * Gets the init parameters of the portlet.
2034     *
2035     * @return init parameters of the portlet
2036     */
2037    public Map<String, String> getInitParams() {
2038        return _initParams;
2039    }
2040
2041    /**
2042     * Sets the init parameters of the portlet.
2043     *
2044     * @param initParams the init parameters of the portlet
2045     */
2046    public void setInitParams(Map<String, String> initParams) {
2047        _initParams = initParams;
2048    }
2049
2050    /**
2051     * Gets expiration cache of the portlet.
2052     *
2053     * @return expiration cache of the portlet
2054     */
2055    public Integer getExpCache() {
2056        return _expCache;
2057    }
2058
2059    /**
2060     * Sets expiration cache of the portlet.
2061     *
2062     * @param expCache expiration cache of the portlet
2063     */
2064    public void setExpCache(Integer expCache) {
2065        _expCache = expCache;
2066    }
2067
2068    /**
2069     * Gets the portlet modes of the portlet.
2070     *
2071     * @return portlet modes of the portlet
2072     */
2073    public Map<String, Set<String>> getPortletModes() {
2074        return _portletModes;
2075    }
2076
2077    /**
2078     * Sets the portlet modes of the portlet.
2079     *
2080     * @param portletModes the portlet modes of the portlet
2081     */
2082    public void setPortletModes(Map<String, Set<String>> portletModes) {
2083        _portletModes = portletModes;
2084    }
2085
2086    /**
2087     * Returns true if the portlet supports the specified mime type and portlet
2088     * mode.
2089     *
2090     * @return true if the portlet supports the specified mime type and
2091     *         portlet mode
2092     */
2093    public boolean hasPortletMode(String mimeType, PortletMode portletMode) {
2094        if (mimeType == null) {
2095            mimeType = ContentTypes.TEXT_HTML;
2096        }
2097
2098        Set<String> mimeTypePortletModes = _portletModes.get(mimeType);
2099
2100        if (mimeTypePortletModes == null) {
2101            return false;
2102        }
2103
2104        if (mimeTypePortletModes.contains(portletMode.toString())) {
2105            return true;
2106        }
2107        else {
2108            return false;
2109        }
2110    }
2111
2112    /**
2113     * Gets a list of all portlet modes supported by the portlet.
2114     *
2115     * @return a list of all portlet modes supported by the portlet
2116     */
2117    public Set<String> getAllPortletModes() {
2118        Set<String> allPortletModes = new TreeSet<String>();
2119
2120        Iterator<Map.Entry <String, Set<String>>> itr1 =
2121            _portletModes.entrySet().iterator();
2122
2123        while (itr1.hasNext()) {
2124            Map.Entry<String, Set<String>> entry = itr1.next();
2125
2126            Set<String> mimeTypePortletModes = entry.getValue();
2127
2128            Iterator<String> itr2 = mimeTypePortletModes.iterator();
2129
2130            while (itr2.hasNext()) {
2131                String portletMode = itr2.next();
2132
2133                allPortletModes.add(portletMode);
2134            }
2135        }
2136
2137        return allPortletModes;
2138    }
2139
2140    /**
2141     * Returns true if the portlet supports more than one mime type.
2142     *
2143     * @return true if the portlet supports more than one mime type
2144     */
2145    public boolean hasMultipleMimeTypes() {
2146        if (_portletModes.size() > 1) {
2147            return true;
2148        }
2149        else {
2150            return false;
2151        }
2152    }
2153
2154    /**
2155     * Gets the window states of the portlet.
2156     *
2157     * @return window states of the portlet
2158     */
2159    public Map<String, Set<String>> getWindowStates() {
2160        return _windowStates;
2161    }
2162
2163    /**
2164     * Sets the window states of the portlet.
2165     *
2166     * @param windowStates the window states of the portlet
2167     */
2168    public void setWindowStates(Map<String, Set<String>> windowStates) {
2169        _windowStates = windowStates;
2170    }
2171
2172    /**
2173     * Returns true if the portlet supports the specified mime type and window
2174     * state.
2175     *
2176     * @return true if the portlet supports the specified mime type and
2177     *         window state
2178     */
2179    public boolean hasWindowState(String mimeType, WindowState windowState) {
2180        if (mimeType == null) {
2181            mimeType = ContentTypes.TEXT_HTML;
2182        }
2183
2184        Set<String> mimeTypeWindowStates = _windowStates.get(mimeType);
2185
2186        if (mimeTypeWindowStates == null) {
2187            return false;
2188        }
2189
2190        if (mimeTypeWindowStates.contains(windowState.toString())) {
2191            return true;
2192        }
2193        else {
2194            return false;
2195        }
2196    }
2197
2198    /**
2199     * Gets a list of all window states supported by the portlet.
2200     *
2201     * @return a list of all window states supported by the portlet
2202     */
2203    public Set<String> getAllWindowStates() {
2204        Set<String> allWindowStates = new TreeSet<String>();
2205
2206        Iterator<Map.Entry <String, Set<String>>> itr1 =
2207            _windowStates.entrySet().iterator();
2208
2209        while (itr1.hasNext()) {
2210            Map.Entry<String, Set<String>> entry = itr1.next();
2211
2212            Set<String> mimeTypeWindowStates = entry.getValue();
2213
2214            Iterator<String> itr2 = mimeTypeWindowStates.iterator();
2215
2216            while (itr2.hasNext()) {
2217                String windowState = itr2.next();
2218
2219                allWindowStates.add(windowState);
2220            }
2221        }
2222
2223        return allWindowStates;
2224    }
2225
2226    /**
2227     * Gets the supported locales of the portlet.
2228     *
2229     * @return supported locales of the portlet
2230     */
2231    public Set<String> getSupportedLocales() {
2232        return _supportedLocales;
2233    }
2234
2235    /**
2236     * Sets the supported locales of the portlet.
2237     *
2238     * @param supportedLocales the supported locales of the portlet
2239     */
2240    public void setSupportedLocales(Set<String> supportedLocales) {
2241        _supportedLocales = supportedLocales;
2242    }
2243
2244    /**
2245     * Gets the resource bundle of the portlet.
2246     *
2247     * @return resource bundle of the portlet
2248     */
2249    public String getResourceBundle() {
2250        return _resourceBundle;
2251    }
2252
2253    /**
2254     * Sets the resource bundle of the portlet.
2255     *
2256     * @param resourceBundle the resource bundle of the portlet
2257     */
2258    public void setResourceBundle(String resourceBundle) {
2259        _resourceBundle = resourceBundle;
2260    }
2261
2262    /**
2263     * Gets the portlet info of the portlet.
2264     *
2265     * @return portlet info of the portlet
2266     */
2267    public PortletInfo getPortletInfo() {
2268        return _portletInfo;
2269    }
2270
2271    /**
2272     * Sets the portlet info of the portlet.
2273     *
2274     * @param portletInfo the portlet info of the portlet
2275     */
2276    public void setPortletInfo(PortletInfo portletInfo) {
2277        _portletInfo = portletInfo;
2278    }
2279
2280    /**
2281     * Gets the filters of the portlet.
2282     *
2283     * @return filters of the portlet
2284     */
2285    public Map<String, PortletFilter> getPortletFilters() {
2286        return _portletFilters;
2287    }
2288
2289    /**
2290     * Sets the filters of the portlet.
2291     *
2292     * @param portletFilters the filters of the portlet
2293     */
2294    public void setPortletFilters(Map<String, PortletFilter> portletFilters) {
2295        _portletFilters = portletFilters;
2296    }
2297
2298    /**
2299     * Adds a supported processing event.
2300     */
2301    public void addProcessingEvent(QName processingEvent) {
2302        _processingEvents.add(processingEvent);
2303        _processingEventsByQName.put(
2304            QNameUtil.getKey(processingEvent), processingEvent);
2305    }
2306
2307    /**
2308     * Gets the supported processing event from a namespace URI and a local
2309     * part.
2310     *
2311     * @return the supported processing event from a namespace URI and a
2312     *         local part
2313     */
2314    public QName getProcessingEvent(String uri, String localPart) {
2315        return _processingEventsByQName.get(
2316            QNameUtil.getKey(uri, localPart));
2317    }
2318
2319    /**
2320     * Gets the supported processing events of the portlet.
2321     *
2322     * @return supported processing events of the portlet
2323     */
2324    public Set<QName> getProcessingEvents() {
2325        return _processingEvents;
2326    }
2327
2328    /**
2329     * Sets the supported processing events of the portlet.
2330     *
2331     * @param processingEvents the supported processing events of the portlet
2332     */
2333    public void setProcessingEvents(Set<QName> processingEvents) {
2334        for (QName processingEvent : processingEvents) {
2335            addProcessingEvent(processingEvent);
2336        }
2337    }
2338
2339    /**
2340     * Adds a supported publishing event.
2341     */
2342    public void addPublishingEvent(QName publishingEvent) {
2343        _publishingEvents.add(publishingEvent);
2344    }
2345
2346    /**
2347     * Gets the supported publishing events of the portlet.
2348     *
2349     * @return supported publishing events of the portlet
2350     */
2351    public Set<QName> getPublishingEvents() {
2352        return _publishingEvents;
2353    }
2354
2355    /**
2356     * Sets the supported publishing events of the portlet.
2357     *
2358     * @param publishingEvents the supported publishing events of the portlet
2359     */
2360    public void setPublishingEvents(Set<QName> publishingEvents) {
2361        for (QName publishingEvent : publishingEvents) {
2362            addPublishingEvent(publishingEvent);
2363        }
2364    }
2365
2366    /**
2367     * Adds a supported public render parameter.
2368     *
2369     * @param publicRenderParameter a supported public render parameter
2370     */
2371    public void addPublicRenderParameter(
2372        PublicRenderParameter publicRenderParameter) {
2373
2374        _publicRenderParameters.add(publicRenderParameter);
2375        _publicRenderParametersByIdentifier.put(
2376            publicRenderParameter.getIdentifier(), publicRenderParameter);
2377        _publicRenderParametersByQName.put(
2378            QNameUtil.getKey(publicRenderParameter.getQName()),
2379            publicRenderParameter);
2380    }
2381
2382    /**
2383     * Gets the supported public render parameter from an identifier.
2384     *
2385     * @return the supported public render parameter from an identifier
2386     */
2387    public PublicRenderParameter getPublicRenderParameter(String identifier) {
2388        return _publicRenderParametersByIdentifier.get(identifier);
2389    }
2390
2391    /**
2392     * Gets the supported public render parameter from a namespace URI and a
2393     * local part.
2394     *
2395     * @return the supported public render parameter from a namespace URI
2396     *         and a local part
2397     */
2398    public PublicRenderParameter getPublicRenderParameter(
2399        String uri, String localPart) {
2400
2401        return _publicRenderParametersByQName.get(
2402            QNameUtil.getKey(uri, localPart));
2403    }
2404
2405    /**
2406     * Gets the supported public render parameters of the portlet.
2407     *
2408     * @return the supported public render parameters of the portlet
2409     */
2410    public Set<PublicRenderParameter> getPublicRenderParameters() {
2411        return _publicRenderParameters;
2412    }
2413
2414    /**
2415     * Sets the supported public render parameters of the portlet.
2416     *
2417     * @param publicRenderParameters the supported public render parameters of
2418     *        the portlet
2419     */
2420    public void setPublicRenderParameters(
2421        Set<PublicRenderParameter> publicRenderParameters) {
2422
2423        for (PublicRenderParameter publicRenderParameter :
2424                publicRenderParameters) {
2425
2426            addPublicRenderParameter(publicRenderParameter);
2427        }
2428    }
2429
2430    /**
2431     * Gets the servlet context path of the portlet.
2432     *
2433     * @return the servlet context path of the portlet
2434     */
2435    public String getContextPath() {
2436        String virtualPath = getVirtualPath();
2437
2438        if (Validator.isNotNull(virtualPath)) {
2439            return virtualPath;
2440        }
2441
2442        if (_portletApp.isWARFile()) {
2443            StringBuilder sb = new StringBuilder();
2444
2445            sb.append(StringPool.SLASH);
2446            sb.append(_portletApp.getServletContextName());
2447
2448            return sb.toString();
2449        }
2450        else {
2451            return PortalUtil.getPathContext();
2452        }
2453    }
2454
2455    /**
2456     * Get the application this portlet belongs to.
2457     *
2458     * @return the application this portlet belongs to
2459     */
2460    public PortletApp getPortletApp() {
2461        return _portletApp;
2462    }
2463
2464    /**
2465     * Sets the application this portlet belongs to.
2466     *
2467     * @param portletApp the application this portlet belongs to
2468     */
2469    public void setPortletApp(PortletApp portletApp) {
2470        _portletApp = portletApp;
2471    }
2472
2473    /**
2474     * Returns true if the portlet is found in a WAR file.
2475     *
2476     * @param  portletId the cloned instance portlet id
2477     * @return a cloned instance of the portlet
2478     */
2479    public Portlet getClonedInstance(String portletId) {
2480        if (_clonedInstances == null) {
2481
2482            // LEP-528
2483
2484            return null;
2485        }
2486
2487        Portlet clonedInstance = _clonedInstances.get(portletId);
2488
2489        if (clonedInstance == null) {
2490            clonedInstance = (Portlet)clone();
2491
2492            clonedInstance.setPortletId(portletId);
2493
2494            // Disable caching of cloned instances until we can figure out how
2495            // to elegantly refresh the cache when the portlet is dynamically
2496            // updated by the user. For example, the user might change the
2497            // portlet from one column to the next. Cloned instances that are
2498            // cached would not see the new change. We can then also cache
2499            // static portlet instances.
2500
2501            //_clonedInstances.put(portletId, clonedInstance);
2502        }
2503
2504        return clonedInstance;
2505    }
2506
2507    /**
2508     * Returns true if the portlet is a static portlet that is cannot be moved.
2509     *
2510     * @return true if the portlet is a static portlet that is cannot be
2511     *         moved
2512     */
2513    public boolean getStatic() {
2514        return _staticPortlet;
2515    }
2516
2517    /**
2518     * Returns true if the portlet is a static portlet that is cannot be moved.
2519     *
2520     * @return true if the portlet is a static portlet that is cannot be
2521     *         moved
2522     */
2523    public boolean isStatic() {
2524        return _staticPortlet;
2525    }
2526
2527    /**
2528     * Sets to true if the portlet is a static portlet that is cannot be moved.
2529     *
2530     * @param staticPortlet boolean value for whether the portlet is a static
2531     *        portlet that cannot be moved
2532     */
2533    public void setStatic(boolean staticPortlet) {
2534        _staticPortlet = staticPortlet;
2535    }
2536
2537    /**
2538     * Returns true if the portlet is a static portlet at the start of a list of
2539     * portlets.
2540     *
2541     * @return true if the portlet is a static portlet at the start of a
2542     *         list of portlets
2543     */
2544    public boolean getStaticStart() {
2545        return _staticPortletStart;
2546    }
2547
2548    /**
2549     * Returns true if the portlet is a static portlet at the start of a list of
2550     * portlets.
2551     *
2552     * @return true if the portlet is a static portlet at the start of a
2553     *         list of portlets
2554     */
2555    public boolean isStaticStart() {
2556        return _staticPortletStart;
2557    }
2558
2559    /**
2560     * Sets to true if the portlet is a static portlet at the start of a list of
2561     * portlets.
2562     *
2563     * @param staticPortletStart boolean value for whether the portlet is a
2564     *        static portlet at the start of a list of portlets
2565     */
2566    public void setStaticStart(boolean staticPortletStart) {
2567        _staticPortletStart = staticPortletStart;
2568    }
2569
2570    /**
2571     * Returns true if the portlet is a static portlet at the end of a list of
2572     * portlets.
2573     *
2574     * @return true if the portlet is a static portlet at the end of a
2575     *         list of portlets
2576     */
2577    public boolean getStaticEnd() {
2578        return !_staticPortletStart;
2579    }
2580
2581    /**
2582     * Returns true if the portlet is a static portlet at the end of a list of
2583     * portlets.
2584     *
2585     * @return true if the portlet is a static portlet at the end of a
2586     *         list of portlets
2587     */
2588    public boolean isStaticEnd() {
2589        return !_staticPortletStart;
2590    }
2591
2592    /**
2593     * Returns true if the portlet is an undeployed portlet.
2594     *
2595     * @return true if the portlet is a placeholder of an undeployed portlet
2596     */
2597    public boolean getUndeployedPortlet() {
2598        return _undeployedPortlet;
2599    }
2600
2601    /**
2602     * Returns true if the portlet is an undeployed portlet.
2603     *
2604     * @return true if the portlet is a placeholder of an undeployed portlet
2605     */
2606    public boolean isUndeployedPortlet() {
2607        return _undeployedPortlet;
2608    }
2609
2610    /**
2611     * Set to true if the portlet is an undeployed portlet.
2612     *
2613     * @param undeployedPortlet boolean value for whether the portlet is an
2614     *        undeployed portlet
2615     */
2616    public void setUndeployedPortlet(boolean undeployedPortlet) {
2617        _undeployedPortlet = undeployedPortlet;
2618    }
2619
2620    /**
2621     * Creates and returns a copy of this object.
2622     *
2623     * @return a copy of this object
2624     */
2625    public Object clone() {
2626        Portlet portlet = new PortletImpl(
2627            getPortletId(), getPluginPackage(), getDefaultPluginSetting(),
2628            getCompanyId(), getTimestamp(), getIcon(), getVirtualPath(),
2629            getStrutsPath(), getPortletName(), getDisplayName(),
2630            getPortletClass(), getConfigurationActionClass(), getIndexerClass(),
2631            getOpenSearchClass(), getSchedulerClass(), getPortletURLClass(),
2632            getFriendlyURLMapperClass(), getURLEncoderClass(),
2633            getPortletDataHandlerClass(), getPortletLayoutListenerClass(),
2634            getPollerProcessorClass(), getPopMessageListenerClass(),
2635            getSocialActivityInterpreterClass(),
2636            getSocialRequestInterpreterClass(), getDefaultPreferences(),
2637            getPreferencesValidator(), isPreferencesCompanyWide(),
2638            isPreferencesUniquePerLayout(), isPreferencesOwnedByGroup(),
2639            isUseDefaultTemplate(), isShowPortletAccessDenied(),
2640            isShowPortletInactive(), isActionURLRedirect(),
2641            isRestoreCurrentView(), isMaximizeEdit(), isMaximizeHelp(),
2642            isPopUpPrint(), isLayoutCacheable(), isInstanceable(),
2643            getUserPrincipalStrategy(), isPrivateRequestAttributes(),
2644            isPrivateSessionAttributes(), getRenderWeight(), isAjaxable(),
2645            getHeaderPortalCss(), getHeaderPortletCss(),
2646            getHeaderPortalJavaScript(), getHeaderPortletJavaScript(),
2647            getFooterPortalCss(), getFooterPortletCss(),
2648            getFooterPortalJavaScript(), getFooterPortletJavaScript(),
2649            getCssClassWrapper(), getFacebookIntegration(),
2650            isAddDefaultResource(), getRoles(), getUnlinkedRoles(),
2651            getRoleMappers(), isSystem(), isActive(), isInclude(),
2652            getInitParams(), getExpCache(), getPortletModes(),
2653            getWindowStates(), getSupportedLocales(), getResourceBundle(),
2654            getPortletInfo(), getPortletFilters(), getProcessingEvents(),
2655            getPublishingEvents(), getPublicRenderParameters(),
2656            getPortletApp());
2657
2658        portlet.setId(getId());
2659
2660        return portlet;
2661    }
2662
2663    /**
2664     * Compares this portlet to the specified object.
2665     *
2666     * @param  portlet the portlet to compare this portlet against
2667     * @return the value 0 if the argument portlet is equal to this
2668     *         portlet; a value less than -1 if this portlet is less than
2669     *         the portlet argument; and 1 if this portlet is greater than
2670     *         the portlet argument
2671     */
2672    public int compareTo(Portlet portlet) {
2673        return getPortletId().compareTo(portlet.getPortletId());
2674    }
2675
2676    /**
2677     * Checks whether this portlet is equal to the specified object.
2678     *
2679     * @param  obj the object to compare this portlet against
2680     * @return true if the portlet is equal to the specified object
2681     */
2682    public boolean equals(Object obj) {
2683        Portlet portlet = (Portlet)obj;
2684
2685        return getPortletId().equals(portlet.getPortletId());
2686    }
2687
2688    /**
2689     * Log instance for this class.
2690     */
2691    private static Log _log = LogFactoryUtil.getLog(PortletImpl.class);
2692
2693    /**
2694     * Package this plugin belongs to.
2695     */
2696    private PluginPackage _pluginPackage;
2697
2698    /**
2699     * Plugin settings associated with the portlet.
2700     */
2701    private PluginSetting _defaultPluginSetting;
2702
2703    /**
2704     * The timestamp of the portlet.
2705     */
2706    private long _timestamp;
2707
2708    /**
2709     * The icon of the portlet.
2710     */
2711    private String _icon;
2712
2713    /**
2714     * The virtual path of the portlet.
2715     */
2716    private String _virtualPath;
2717
2718    /**
2719     * The struts path of the portlet.
2720     */
2721    private String _strutsPath;
2722
2723    /**
2724     * The name of the portlet.
2725     */
2726    private String _portletName;
2727
2728    /**
2729     * The display name of the portlet.
2730     */
2731    private String _displayName;
2732
2733    /**
2734     * The name of the portlet class of the portlet.
2735     */
2736    private String _portletClass;
2737
2738    /**
2739     * The configuration action class of the portlet.
2740     */
2741    private String _configurationActionClass;
2742
2743    /**
2744     * The name of the indexer class of the portlet.
2745     */
2746    private String _indexerClass;
2747
2748    /**
2749     * The name of the open search class of the portlet.
2750     */
2751    private String _openSearchClass;
2752
2753    /**
2754     * The name of the scheduler class of the portlet.
2755     */
2756    private String _schedulerClass;
2757
2758    /**
2759     * The name of the portlet URL class of the portlet.
2760     */
2761    private String _portletURLClass;
2762
2763    /**
2764     * The name of the friendly URL mapper class of the portlet.
2765     */
2766    private String _friendlyURLMapperClass;
2767
2768    /**
2769     * The name of the URL encoder class of the portlet.
2770     */
2771    private String _urlEncoderClass;
2772
2773    /**
2774     * The name of the portlet data handler class of the portlet.
2775     */
2776    private String _portletDataHandlerClass;
2777
2778    /**
2779     * The name of the portlet data layout listener class of the portlet.
2780     */
2781    private String _portletLayoutListenerClass;
2782
2783    /**
2784     * The name of the poller processor class of the portlet.
2785     */
2786    private String _pollerProcessorClass;
2787
2788    /**
2789     * The name of the POP message listener class of the portlet.
2790     */
2791    private String _popMessageListenerClass;
2792
2793    /**
2794     * The name of the social activity interpreter class of the portlet.
2795     */
2796    private String _socialActivityInterpreterClass;
2797
2798    /**
2799     * The name of the social request interpreter class of the portlet.
2800     */
2801    private String _socialRequestInterpreterClass;
2802
2803    /**
2804     * The default preferences of the portlet.
2805     */
2806    private String _defaultPreferences;
2807
2808    /**
2809     * The name of the preferences validator class of the portlet.
2810     */
2811    private String _prefsValidator;
2812
2813    /**
2814     * True if preferences are shared across the entire company.
2815     */
2816    private boolean _prefsCompanyWide;
2817
2818    /**
2819     * True if preferences are unique per layout.
2820     */
2821    private boolean _prefsUniquePerLayout = true;
2822
2823    /**
2824     * True if preferences are owned by the group when the portlet is shown in a
2825     * group layout. False if preferences are owned by the user at all times.
2826     */
2827    private boolean _prefsOwnedByGroup = true;
2828
2829    /**
2830     * True if the portlet uses the default template.
2831     */
2832    private boolean _useDefaultTemplate = true;
2833
2834    /**
2835     * True if users are shown that they do not have access to the portlet.
2836     */
2837    private boolean _showPortletAccessDenied =
2838        PropsValues.LAYOUT_SHOW_PORTLET_ACCESS_DENIED;
2839
2840    /**
2841     * True if users are shown that the portlet is inactive.
2842     */
2843    private boolean _showPortletInactive =
2844        PropsValues.LAYOUT_SHOW_PORTLET_INACTIVE;
2845
2846    /**
2847     * True if an action URL for this portlet should cause an auto redirect.
2848     */
2849    private boolean _actionURLRedirect;
2850
2851    /**
2852     * True if the portlet restores to the current view from the maximized
2853     * state.
2854     */
2855    private boolean _restoreCurrentView = true;
2856
2857    /**
2858     * True if the portlet goes into the maximized state when the user goes into
2859     * the edit mode.
2860     */
2861    private boolean _maximizeEdit;
2862
2863    /**
2864     * True if the portlet goes into the maximized state when the user goes into
2865     * the help mode.
2866     */
2867    private boolean _maximizeHelp;
2868
2869    /**
2870     * True if the portlet goes into the pop up state when the user goes into
2871     * the print mode.
2872     */
2873    private boolean _popUpPrint = true;
2874
2875    /**
2876     * True if the portlet can be cached within the layout.
2877     */
2878    private boolean _layoutCacheable;
2879
2880    /**
2881     * True if the portlet can be added multiple times to a layout.
2882     */
2883    private boolean _instanceable;
2884
2885    /**
2886     * The user principal strategy of the portlet.
2887     */
2888    private String _userPrincipalStrategy =
2889        PortletConstants.USER_PRINCIPAL_STRATEGY_USER_ID;
2890
2891    /**
2892     * True if the portlet does not share request attributes with the portal or
2893     * portlets from another WAR.
2894     */
2895    private boolean _privateRequestAttributes = true;
2896
2897    /**
2898     * True if the portlet does not share session attributes with the portal.
2899     */
2900    private boolean _privateSessionAttributes = true;
2901
2902    /**
2903     * Render weight of the portlet.
2904     */
2905    private int _renderWeight = 1;
2906
2907    /**
2908     * True if the portlet can be displayed via Ajax.
2909     */
2910    private boolean _ajaxable = true;
2911
2912    /**
2913     * A list of CSS files that will be referenced from the page's header
2914     * relative to the portal's context path.
2915     */
2916    private List<String> _headerPortalCss;
2917
2918    /**
2919     * A list of CSS files that will be referenced from the page's header
2920     * relative to the portlet's context path.
2921     */
2922    private List<String> _headerPortletCss;
2923
2924    /**
2925     * A list of JavaScript files that will be referenced from the page's header
2926     * relative to the portal's context path.
2927     */
2928    private List<String> _headerPortalJavaScript;
2929
2930    /**
2931     * A list of JavaScript files that will be referenced from the page's header
2932     * relative to the portlet's context path.
2933     */
2934    private List<String> _headerPortletJavaScript;
2935
2936    /**
2937     * A list of CSS files that will be referenced from the page's footer
2938     * relative to the portal's context path.
2939     */
2940    private List<String> _footerPortalCss;
2941
2942    /**
2943     * A list of CSS files that will be referenced from the page's footer
2944     * relative to the portlet's context path.
2945     */
2946    private List<String> _footerPortletCss;
2947
2948    /**
2949     * A list of JavaScript files that will be referenced from the page's footer
2950     * relative to the portal's context path.
2951     */
2952    private List<String> _footerPortalJavaScript;
2953
2954    /**
2955     * A list of JavaScript files that will be referenced from the page's footer
2956     * relative to the portlet's context path.
2957     */
2958    private List<String> _footerPortletJavaScript;
2959
2960    /**
2961     * The name of the CSS class that will be injected in the DIV that wraps
2962     * this portlet.
2963     */
2964    private String _cssClassWrapper = StringPool.BLANK;
2965
2966    /**
2967     * The Facebook integration method of the portlet.
2968     */
2969    private String _facebookIntegration =
2970        PortletConstants.FACEBOOK_INTEGRATION_IFRAME;
2971
2972    /**
2973     * True if default resources for the portlet are added to a page.
2974     */
2975    private boolean _addDefaultResource;
2976
2977    /**
2978     * An array of required roles of the portlet.
2979     */
2980    private String[] _rolesArray;
2981
2982    /**
2983     * The unlinked roles of the portlet.
2984     */
2985    private Set<String> _unlinkedRoles;
2986
2987    /**
2988     * The role mappers of the portlet.
2989     */
2990    private Map<String, String> _roleMappers;
2991
2992    /**
2993     * True if the portlet is a system portlet that a user cannot manually add
2994     * to their page.
2995     */
2996    private boolean _system;
2997
2998    /**
2999     * True to include the portlet and make it available to be made active.
3000     */
3001    private boolean _include = true;
3002
3003    /**
3004     * The init parameters of the portlet.
3005     */
3006    private Map<String, String> _initParams;
3007
3008    /**
3009     * The expiration cache of the portlet.
3010     */
3011    private Integer _expCache;
3012
3013    /**
3014     * The portlet modes of the portlet.
3015     */
3016    private Map<String, Set<String>> _portletModes;
3017
3018    /**
3019     * The window states of the portlet.
3020     */
3021    private Map<String, Set<String>> _windowStates;
3022
3023    /**
3024     * The supported locales of the portlet.
3025     */
3026    private Set<String> _supportedLocales;
3027
3028    /**
3029     * The resource bundle of the portlet.
3030     */
3031    private String _resourceBundle;
3032
3033    /**
3034     * The portlet info of the portlet.
3035     */
3036    private PortletInfo _portletInfo;
3037
3038    /**
3039     * The filters of the portlet.
3040     */
3041    private Map<String, PortletFilter> _portletFilters;
3042
3043    /**
3044     * The supported processing events of the portlet.
3045     */
3046    private Set<QName> _processingEvents = new HashSet<QName>();
3047
3048    /**
3049     * Map of the supported processing events of the portlet keyed by the QName.
3050     */
3051    private Map<String, QName> _processingEventsByQName =
3052        new HashMap<String, QName>();
3053
3054    /**
3055     * The supported publishing events of the portlet.
3056     */
3057    private Set<QName> _publishingEvents = new HashSet<QName>();
3058
3059    /**
3060     * The supported public render parameters of the portlet.
3061     */
3062    private Set<PublicRenderParameter> _publicRenderParameters =
3063        new HashSet<PublicRenderParameter>();
3064
3065    /**
3066     * Map of the supported public render parameters of the portlet keyed by the
3067     * identifier.
3068     */
3069    private Map<String, PublicRenderParameter>
3070        _publicRenderParametersByIdentifier =
3071            new HashMap<String, PublicRenderParameter>();
3072
3073    /**
3074     * Map of the supported public render parameters of the portlet keyed by the
3075     * QName.
3076     */
3077    private Map<String, PublicRenderParameter>
3078        _publicRenderParametersByQName =
3079            new HashMap<String, PublicRenderParameter>();
3080
3081    /**
3082     * The application this portlet belongs to.
3083     */
3084    private PortletApp _portletApp;
3085
3086    /**
3087     * The cloned instances of the portlet.
3088     */
3089    private Map<String, Portlet> _clonedInstances;
3090
3091    /**
3092     * True if the portlet is a static portlet that is cannot be moved.
3093     */
3094    private boolean _staticPortlet;
3095
3096    /**
3097     * True if the portlet is a static portlet at the start of a list of
3098     * portlets.
3099     */
3100    private boolean _staticPortletStart;
3101
3102    /**
3103     * True if the portlet is an undeployed portlet.
3104     */
3105    private boolean _undeployedPortlet = false;
3106
3107}