1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.util.StringPool;
26  import com.liferay.portal.kernel.util.Validator;
27  import com.liferay.portal.model.EventDefinition;
28  import com.liferay.portal.model.PortletApp;
29  import com.liferay.portal.model.PortletFilter;
30  import com.liferay.portal.model.PortletURLListener;
31  import com.liferay.portal.model.PublicRenderParameter;
32  
33  import java.util.HashMap;
34  import java.util.LinkedHashMap;
35  import java.util.LinkedHashSet;
36  import java.util.Map;
37  import java.util.Set;
38  
39  import javax.xml.XMLConstants;
40  
41  /**
42   * <a href="PortletAppImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * @author Brian Wing Shun Chan
45   *
46   */
47  public class PortletAppImpl implements PortletApp {
48  
49      public PortletAppImpl(String servletContextName) {
50          _servletContextName = servletContextName;
51  
52          if (Validator.isNotNull(_servletContextName)) {
53              _warFile = true;
54          }
55          else {
56              _warFile = false;
57          }
58      }
59  
60      public String getServletContextName() {
61          return _servletContextName;
62      }
63  
64      public Set<String> getServletURLPatterns() {
65          return _servletURLPatterns;
66      }
67  
68      public Set<String> getUserAttributes() {
69          return _userAttributes;
70      }
71  
72      public Map<String, String> getCustomUserAttributes() {
73          return _customUserAttributes;
74      }
75  
76      public void addPortletFilter(PortletFilter portletFilter) {
77          _portletFilters.add(portletFilter);
78          _portletFiltersByFilterName.put(
79              portletFilter.getFilterName(), portletFilter);
80      }
81  
82      public PortletFilter getPortletFilter(String filterName) {
83          return _portletFiltersByFilterName.get(filterName);
84      }
85  
86      public Set<PortletFilter> getPortletFilters() {
87          return _portletFilters;
88      }
89  
90      public String getDefaultNamespace() {
91          return _defaultNamespace;
92      }
93  
94      public void setDefaultNamespace(String defaultNamespace) {
95          _defaultNamespace = defaultNamespace;
96      }
97  
98      public void addEventDefinition(EventDefinition eventDefinition) {
99          _eventDefinitions.add(eventDefinition);
100     }
101 
102     public void addPublicRenderParameter(
103         PublicRenderParameter publicRenderParameter) {
104 
105         _publicRenderParameters.add(publicRenderParameter);
106         _publicRenderParametersByIdentifier.put(
107             publicRenderParameter.getIdentifier(), publicRenderParameter);
108     }
109 
110     public PublicRenderParameter getPublicRenderParameter(String identifier) {
111         return _publicRenderParametersByIdentifier.get(identifier);
112     }
113 
114     public void addPortletURLListener(PortletURLListener portletURLListener) {
115         _portletURLListeners.add(portletURLListener);
116         _portletURLListenersByListenerClass.put(
117             portletURLListener.getListenerClass(), portletURLListener);
118     }
119 
120     public PortletURLListener getPortletURLListener(String listenerClass) {
121         return _portletURLListenersByListenerClass.get(listenerClass);
122     }
123 
124     public Set<PortletURLListener> getPortletURLListeners() {
125         return _portletURLListeners;
126     }
127 
128     public Map<String, String[]> getContainerRuntimeOptions() {
129         return _containerRuntimeOptions;
130     }
131 
132     public boolean isWARFile() {
133         return _warFile;
134     }
135 
136     private String _servletContextName = StringPool.BLANK;
137     private Set<String> _servletURLPatterns = new LinkedHashSet<String>();
138     private Set<String> _userAttributes = new LinkedHashSet<String>();
139     private Map<String, String> _customUserAttributes =
140         new LinkedHashMap<String, String>();
141     private Set<PortletFilter> _portletFilters =
142         new LinkedHashSet<PortletFilter>();
143     private Map<String, PortletFilter> _portletFiltersByFilterName =
144         new HashMap<String, PortletFilter>();
145     private String _defaultNamespace = XMLConstants.NULL_NS_URI;
146     private Set<EventDefinition> _eventDefinitions =
147         new LinkedHashSet<EventDefinition>();
148     private Set<PublicRenderParameter> _publicRenderParameters =
149         new LinkedHashSet<PublicRenderParameter>();
150     private Map<String, PublicRenderParameter>
151         _publicRenderParametersByIdentifier =
152             new HashMap<String, PublicRenderParameter>();
153     private Set<PortletURLListener> _portletURLListeners =
154         new LinkedHashSet<PortletURLListener>();
155     private Map<String, PortletURLListener>
156         _portletURLListenersByListenerClass =
157             new HashMap<String, PortletURLListener>();
158     private Map<String, String[]> _containerRuntimeOptions =
159         new HashMap<String, String[]>();
160     private boolean _warFile;
161 
162 }