1 48 49 package com.caucho.portal.generic; 50 51 import javax.portlet.PortalContext; 52 import javax.portlet.PortletMode; 53 import javax.portlet.PortletRequest; 54 import javax.portlet.WindowState; 55 import java.util.Collections ; 56 import java.util.Enumeration ; 57 import java.util.LinkedHashMap ; 58 import java.util.Map ; 59 import java.util.Set ; 60 import java.util.logging.Logger ; 61 62 65 public class GenericPortal 66 implements Portal, PortalContext 67 { 68 static final public Logger log = 69 Logger.getLogger(GenericPortal.class.getName()); 70 71 private String _portalInfo = "GenericPortal/1.0"; 72 private String _reservedNamespace = "__"; 73 private Map <String , String > _propertyMap; 74 private Set <WindowState> _supportedWindowStates; 75 private Set <PortletMode> _supportedPortletModes; 76 77 private Set <String > _userAttributeNames; 78 79 private PreferencesStore _preferencesStore; 80 private UserAttributeStore _userAttributeStore; 81 82 private Cache _cache; 83 private BufferFactory _bufferFactory; 84 85 private boolean _isInit; 86 87 public PortalContext getPortalContext() 88 { 89 return this; 90 } 91 92 96 public void setPortalInfo(String portalInfo) 97 { 98 _portalInfo = portalInfo; 99 } 100 101 104 public String getPortalInfo() 105 { 106 return _portalInfo; 107 } 108 111 public void setReservedNamespace(String reservedNamespace) 112 { 113 _reservedNamespace = reservedNamespace; 114 } 115 116 119 public String getReservedNamespace() 120 { 121 return _reservedNamespace; 122 } 123 124 127 public void setProperty(String name, String value) 128 { 129 if (_propertyMap == null) 130 _propertyMap = new LinkedHashMap <String , String >(); 131 132 _propertyMap.put(name, value); 133 } 134 135 138 public String getProperty(String name) 139 { 140 if (_propertyMap == null) 141 return null; 142 143 return _propertyMap.get(name); 144 } 145 146 149 public Enumeration getPropertyNames() 150 { 151 if (_propertyMap == null) 152 return Collections.enumeration(Collections.EMPTY_LIST); 153 else 154 return Collections.enumeration(_propertyMap.keySet()); 155 } 156 157 163 public void setSupportedPortletModes(Set <PortletMode> portletModes) 164 { 165 _supportedPortletModes = portletModes; 166 } 167 168 171 public Enumeration getSupportedPortletModes() 172 { 173 if (_supportedPortletModes == null) 174 return Collections.enumeration(Collections.EMPTY_LIST); 175 else 176 return Collections.<PortletMode>enumeration(_supportedPortletModes); 177 } 178 179 182 public boolean isPortletModeAllowed(PortletRequest portletRequest, 183 PortletMode portletMode) 184 { 185 if (_supportedPortletModes == null) 186 return true; 187 else 188 return _supportedPortletModes.contains(portletMode); 189 } 190 191 197 public void setSupportedWindowStates(Set <WindowState> windowStates) 198 { 199 _supportedWindowStates = windowStates; 200 } 201 202 205 public Enumeration getSupportedWindowStates() 206 { 207 208 if (_supportedWindowStates == null) 209 return Collections.enumeration(Collections.EMPTY_LIST); 210 else 211 return Collections.enumeration(_supportedWindowStates); 212 } 213 214 217 public boolean isWindowStateAllowed(PortletRequest portletRequest, 218 WindowState windowState) 219 { 220 if (_supportedWindowStates == null) 221 return true; 222 else 223 return _supportedWindowStates.contains(windowState); 224 } 225 226 232 public void setPreferencesStore(PreferencesStore preferencesStore) 233 { 234 _preferencesStore = preferencesStore; 235 } 236 237 240 public PreferencesStore getPreferencesStore() 241 { 242 if (_preferencesStore == null) 243 _preferencesStore = new SessionPreferencesStore(); 244 245 return _preferencesStore; 246 } 247 248 252 public void setUserAttributeNames(Set <String > userAttributeNames) 253 { 254 if (_userAttributeNames != null) 255 throw new IllegalArgumentException ("user-attribute-names already set"); 256 257 _userAttributeNames = userAttributeNames; 258 } 259 260 263 public Set <String > getUserAttributeNames() 264 { 265 return _userAttributeNames; 266 } 267 268 274 public void setUserAttributeStore(UserAttributeStore userAttributeStore) 275 { 276 _userAttributeStore = userAttributeStore; 277 } 278 279 282 public UserAttributeStore getUserAttributeStore() 283 { 284 return _userAttributeStore; 285 } 286 287 291 public void setCache(Cache cache) 292 { 293 _cache = cache; 294 throw new UnsupportedOperationException ("cache not currently implemented"); 295 } 296 297 300 public Cache getCache() 301 { 302 return _cache; 303 } 304 305 308 public void setBufferFactory(BufferFactory bufferFactory) 309 { 310 _bufferFactory = bufferFactory; 311 } 312 313 316 public BufferFactory getBufferFactory() 317 { 318 if (_bufferFactory == null) 319 _bufferFactory = new BufferFactoryImpl(); 320 321 return _bufferFactory; 322 } 323 } 324 325 | Popular Tags |