1 16 17 package org.apache.jetspeed.portal; 18 19 import java.util.Hashtable ; 21 import java.util.Map ; 22 23 import org.apache.turbine.services.servlet.TurbineServlet; 25 26 import org.apache.jetspeed.capability.CapabilityMap; 28 import org.apache.jetspeed.om.SecurityReference; 29 import org.apache.jetspeed.util.BaseConfig; 30 import org.apache.jetspeed.util.MetaData; 31 32 39 public class BasePortletConfig extends BaseConfig implements PortletConfig 40 { 41 42 private String url; 43 private MetaData metainfo; 44 private PortletSet.Constraints layoutConstraints = null; 45 private int layoutPosition = -1; 46 private PortletSkin skin; 47 private transient PortletSet currentSet; 48 private CapabilityMap cm = null; 49 private boolean cachedOnURL = true; 50 private String pageId; 51 private String portletId; 52 private SecurityReference securityRef = null; 53 54 57 public void init( String url, Map init_params ) 58 { 59 if (init_params == null) 60 { 61 this.setInitParameters(new Hashtable ()); 62 } 63 else 64 { 65 this.setInitParameters( init_params ); 66 } 67 68 this.setURL( url ); 69 } 70 71 74 public PortletSet getPortletSet() 75 { 76 return this.currentSet; 77 } 78 79 82 public void setPortletSet(PortletSet set) 83 { 84 this.currentSet=set; 85 } 86 87 91 public Map getLayout() 92 { 93 return this.layoutConstraints; 94 } 95 96 100 public void setLayout(Map constraints) 101 { 102 } 104 105 111 public Map getSkin() 112 { 113 return this.skin; 114 } 115 116 121 public void setSkin(Map skin) 122 { 123 } 125 126 129 public int getPosition() 130 { 131 return this.layoutPosition; 132 } 133 134 137 public void setPosition(int position) 138 { 139 this.layoutPosition=position; 140 } 141 142 146 public MetaData getMetainfo() 147 { 148 return this.metainfo; 149 } 150 151 154 public void setMetainfo(MetaData metainfo) 155 { 156 this.metainfo = metainfo; 157 } 158 159 167 public String getURL() 168 { 169 return this.url; 170 } 171 172 175 public void setURL(String url) 176 { 177 if ( url == null ) 178 { 179 return; 180 } 181 182 if ( url.indexOf("://") < 0 ) 185 { 186 this.url = TurbineServlet.getResource( url ).toString(); 187 } 188 else 189 { 190 this.url = url; 191 } 192 } 193 194 public boolean isCachedOnURL() 195 { 196 return cachedOnURL; 197 } 198 199 public void setCachedOnURL(boolean cached) 200 { 201 cachedOnURL = cached; 202 } 203 204 205 211 public String getLayout(String name, String defaultValue) 212 { 213 String value = null; 214 215 if (name!=null && layoutConstraints != null) 216 { 217 value=(String )layoutConstraints.get(name.toLowerCase()); 218 } 219 220 if (value==null) 221 { 222 value=defaultValue; 223 } 224 225 return value; 226 } 227 228 234 public String getSkin(String name, String defaultValue) 235 { 236 String value = null; 237 238 try 239 { 240 value=(String )skin.get(name.toLowerCase()); 241 if (value==null) 242 { 243 value=(String )currentSet.getPortletConfig().getSkin(name, defaultValue); 244 } 245 if (value==null) value=defaultValue; 246 } 247 catch (RuntimeException e) 248 { 249 value=defaultValue; 250 } 251 252 return value; 253 } 254 255 258 public void setSkin(String name, String value) 259 { 260 if (name!=null) 261 { 262 if (getSkin()==null) 263 { 264 setPortletSkin(getPortletSkin()); 265 } 266 267 if (value==null) 268 { 269 getSkin().remove(name); 270 } 271 else 272 { 273 getSkin().put(name,value); 274 } 275 } 276 } 277 278 288 public PortletSkin getPortletSkin() 289 { 290 if ((this.skin==null)&&(getPortletSet()!=null)) 291 { 292 return getPortletSet().getPortletConfig().getPortletSkin(); 293 } 294 295 return this.skin; 296 } 297 298 303 public void setPortletSkin(PortletSkin skin) 304 { 305 this.skin = skin; 306 } 307 308 313 public PortletSet.Constraints getConstraints() 314 { 315 return this.layoutConstraints; 316 } 317 318 324 public void setConstraints(PortletSet.Constraints constraints) 325 { 326 this.layoutConstraints = constraints; 327 } 328 329 331 public CapabilityMap getCapabilityMap() 332 { 333 return this.cm; 334 } 335 336 338 public void setCapabilityMap( CapabilityMap cm ) 339 { 340 this.cm = cm; 341 } 342 343 public void setPageId(String pageId) 344 { 345 this.pageId = pageId; 346 } 347 348 public String getPageId() 349 { 350 return this.pageId; 351 } 352 353 public void setPortletId(String portletId) 354 { 355 this.portletId = portletId; 356 } 357 358 public String getPortletId() 359 { 360 return this.portletId; 361 } 362 363 366 public SecurityReference getSecurityRef() 367 { 368 return this.securityRef; 369 } 370 371 374 public void setSecurityRef(SecurityReference securityRef) 375 { 376 this.securityRef = securityRef; 377 } 378 379 } 380 | Popular Tags |