1 16 package org.apache.cocoon.portal.pluto.om; 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.HashMap ; 21 import java.util.Locale ; 22 import java.util.Vector ; 23 24 import javax.servlet.ServletContext ; 25 26 import org.apache.pluto.om.common.Description; 27 import org.apache.pluto.om.common.DescriptionSet; 28 import org.apache.pluto.om.common.DisplayName; 29 import org.apache.pluto.om.common.DisplayNameSet; 30 import org.apache.pluto.om.common.ObjectID; 31 import org.apache.pluto.om.common.ParameterSet; 32 import org.apache.pluto.om.common.SecurityRoleSet; 33 import org.apache.pluto.om.portlet.PortletApplicationDefinition; 34 import org.apache.pluto.om.servlet.ServletDefinitionList; 35 import org.apache.pluto.om.servlet.WebApplicationDefinition; 36 import org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl; 37 import org.apache.cocoon.portal.pluto.om.common.ParameterSetImpl; 38 import org.apache.cocoon.portal.pluto.om.common.ResourceRefSet; 39 import org.apache.cocoon.portal.pluto.om.common.SecurityRoleSetImpl; 40 import org.apache.cocoon.portal.pluto.om.common.Support; 41 import org.apache.cocoon.portal.pluto.om.common.DescriptionSetImpl; 42 import org.apache.cocoon.portal.pluto.om.common.DisplayNameSetImpl; 43 import org.apache.cocoon.portal.pluto.om.common.TagDefinitionSet; 44 45 52 public class WebApplicationDefinitionImpl 53 implements WebApplicationDefinition, Support { 54 55 56 public String icon; 58 public String distributable; 59 public String sessionConfig; 60 public String mimeMapping; 61 public String welcomeFileList; 62 public String errorPage; 63 public String taglib; 64 public String resourceRef; 65 public String loginConfig; 66 public String securityRole; 67 public String envEntry; 68 public String ejbRef; 69 private Collection castorMimeMappings = new ArrayList (); 70 private Collection securityConstraints = new ArrayList (); 72 73 private String contextPath; 74 private DescriptionSet descriptions = new DescriptionSetImpl(); 75 private DisplayNameSet displayNames = new DisplayNameSetImpl(); 76 private String id = ""; 77 private ParameterSet initParams = new ParameterSetImpl(); 78 79 private ObjectID objectId; 80 private Collection servletMappings = new ArrayList (); 81 private ServletDefinitionList servlets = new ServletDefinitionListImpl(); 82 private SecurityRoleSet securityRoles = new SecurityRoleSetImpl(); 83 84 private TagDefinitionSet taglibs = new TagDefinitionSet(); 87 private ResourceRefSet castorResourceRef = new ResourceRefSet(); 88 90 92 public ObjectID getId() { 93 if (this.objectId == null) { 94 this.objectId = ObjectIDImpl.createFromString(id); 95 } 96 return this.objectId; 97 } 98 99 102 public DisplayName getDisplayName(Locale locale) { 103 return displayNames.get(locale); 104 } 105 106 109 public Description getDescription(Locale locale) { 110 return descriptions.get(locale); 111 } 112 113 116 public ParameterSet getInitParameterSet() { 117 return initParams; 118 } 119 120 123 public ServletDefinitionList getServletDefinitionList() { 124 return servlets; 125 } 126 127 130 public ServletContext getServletContext(ServletContext servletContext) { 131 return servletContext.getContext(contextPath); 132 } 133 134 137 public String getContextRoot() { 138 return contextPath; 139 } 140 141 144 public void postBuild(Object parameter) throws Exception { 145 } 147 148 151 public void postLoad(Object parameter) throws Exception { 152 Vector structure = (Vector )parameter; 153 PortletApplicationDefinition portletApplication = (PortletApplicationDefinition)structure.get(0); 154 155 ((Support)portletApplication).postLoad(this); 156 157 ((Support)servlets).postLoad(this); 158 159 ((Support)descriptions).postLoad(parameter); 160 ((Support)displayNames).postLoad(parameter); 161 162 } 163 164 167 public void postStore(Object parameter) throws Exception { 168 ((Support)servlets).postStore(this); 169 } 170 171 174 public void preBuild(Object parameter) throws Exception { 175 Vector structure = (Vector )parameter; 176 PortletApplicationDefinition portletApplication = (PortletApplicationDefinition)structure.get(0); 177 String contextString = (String )structure.get(1); 178 179 setContextRoot(contextString); 180 181 HashMap servletMap = new HashMap (1); 182 Vector structure2 = new Vector (); 183 structure2.add(this); 184 structure2.add(servletMappings); 185 structure2.add(servletMap); 186 187 ((Support)servlets).preBuild(structure2); 188 189 Vector structure3 = new Vector (); 190 structure3.add(contextString); 191 structure3.add(this); 192 structure3.add(servletMap); 193 ((Support)portletApplication).preBuild(structure3); 194 } 195 196 199 public void preStore(Object parameter) throws Exception { 200 Vector structure = (Vector )parameter; 201 PortletApplicationDefinition portletApplication = (PortletApplicationDefinition)structure.get(0); 202 203 ((Support)portletApplication).preStore(null); 204 205 ((Support)servlets).preStore(this); 206 } 207 208 210 public String getCastorId() { 211 if (id.length() > 0) { 212 return getId().toString(); 213 } 214 return null; 215 } 216 217 public Collection getCastorInitParams() { 218 return(ParameterSetImpl)initParams; 219 } 220 221 public Collection getCastorServlets() { 222 return(ServletDefinitionListImpl)servlets; 223 } 224 225 public Collection getCastorDisplayNames() { 226 return(DisplayNameSetImpl)displayNames; 227 } 228 229 public Collection getCastorDescriptions() { 230 return(DescriptionSetImpl)descriptions; 231 } 232 233 public SecurityRoleSet getSecurityRoles() { 234 return securityRoles; 235 } 236 237 public Collection getServletMappings() { 238 return servletMappings; 239 } 240 public void setCastorId(String id) { 241 setId(id); 242 } 243 244 protected void setContextRoot(String contextPath) 245 { 246 if (contextPath != null && contextPath.endsWith(".war")) 248 { 249 contextPath = contextPath.substring(0, contextPath.length()-4); 250 } 251 this.contextPath = contextPath; 252 } 253 254 public void setDescriptions(DescriptionSet descriptions) { 255 this.descriptions = descriptions; 256 } 257 258 public void setDisplayNames(DisplayNameSet displayNames) { 259 this.displayNames = displayNames; 260 } 261 262 public void setCastorDescriptions(DescriptionSet castorDescriptions) { 263 this.descriptions = castorDescriptions; 264 } 265 266 public void setCastorDisplayNames(DisplayNameSet castorDisplayNames) { 267 this.displayNames = castorDisplayNames; 268 } 269 270 public void setId(String id) { 271 this.id = id; 272 objectId = null; 273 } 274 275 277 280 public TagDefinitionSet getTagDefinitionSet() { 281 return taglibs; 282 } 283 284 public Collection getCastorTagDefinitions() { 285 return taglibs; 286 } 287 288 public void setCastorTagDefinitions(TagDefinitionSet taglibs) { 289 this.taglibs = taglibs; 290 } 291 292 public ResourceRefSet getCastorResourceRefSet() { 293 return castorResourceRef; 294 } 295 296 public void setCastorResourceRefSet(ResourceRefSet resourceRefs) { 297 castorResourceRef = resourceRefs; 298 } 299 301 304 public Collection getCastorMimeMappings() { 305 return castorMimeMappings; 306 } 307 308 public Collection getSecurityConstraints() { 309 return securityConstraints; 310 } 311 312 315 public void setCastorMimeMappings(Collection castorMimeMappings) { 316 this.castorMimeMappings = castorMimeMappings; 317 } 318 319 public void setSecurityConstraints(Collection securityConstraints) { 320 this.securityConstraints = securityConstraints; 321 } 322 } 323 | Popular Tags |