1 16 package org.apache.cocoon.portal.pluto.om; 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.Map ; 21 import java.util.Vector ; 22 23 import org.apache.pluto.om.common.ObjectID; 24 import org.apache.pluto.om.portlet.PortletApplicationDefinition; 25 import org.apache.pluto.om.portlet.PortletDefinitionList; 26 import org.apache.pluto.om.servlet.WebApplicationDefinition; 27 import org.apache.cocoon.portal.pluto.om.common.AbstractSupportSet; 28 import org.apache.cocoon.portal.pluto.om.common.Support; 29 30 37 public class PortletApplicationDefinitionImpl 38 extends AbstractSupportSet 39 implements PortletApplicationDefinition { 40 41 protected String GUID; 42 43 protected String appId; 44 protected String version; 45 protected PortletDefinitionRegistryImpl registry; 46 47 48 private ArrayList customPortletMode = new ArrayList (); 49 private ArrayList customPortletState = new ArrayList (); 50 private ArrayList userAttribute = new ArrayList (); 51 private ArrayList securityConstraint = new ArrayList (); 52 53 private PortletDefinitionListImpl portlets = new PortletDefinitionListImpl(); 54 55 private WebApplicationDefinition webApplication; 56 57 private ObjectID objectId; 58 59 private String contextPath; 60 61 65 public PortletDefinitionRegistryImpl getRegistry() { 66 return this.registry; 67 } 68 69 73 public void setRegistry(PortletDefinitionRegistryImpl registry) { 74 this.registry = registry; 75 } 76 77 80 public ObjectID getId() { 81 if ( this.objectId == null ) { 82 this.objectId = org.apache.cocoon.portal.pluto.om.common.ObjectIDImpl.createFromString(getGUID()); 83 } 84 return this.objectId; 85 } 86 87 90 public String getVersion() { 91 return this.version; 92 } 93 94 97 public PortletDefinitionList getPortletDefinitionList() { 98 return this.portlets; 99 } 100 101 104 public WebApplicationDefinition getWebApplicationDefinition() { 105 return this.webApplication; 106 } 107 108 111 public void postLoad(Object parameter) throws Exception { 112 ((Support)portlets).postLoad(parameter); 113 } 114 115 118 public void preBuild(Object parameter) 119 throws Exception { 120 Vector structure = (Vector )parameter; 121 String contextRoot = (String )structure.get(0); 122 WebApplicationDefinition webApplication = (WebApplicationDefinition)structure.get(1); 123 Map servletMap = (Map )structure.get(2); 124 125 this.setContextRoot(contextRoot); 126 127 setWebApplicationDefinition(webApplication); 128 129 Vector structure2 = new Vector (); 130 structure2.add(this); 131 structure2.add(servletMap); 132 133 ((Support)portlets).preBuild(structure2); 134 135 } 136 137 140 public void postBuild(Object parameter) throws Exception { 141 } 143 144 147 public void preStore(Object parameter) throws Exception { 148 ((Support)portlets).preStore(parameter); 149 } 150 151 154 public void postStore(Object parameter) throws Exception { 155 ((Support)portlets).postStore(parameter); 156 } 157 158 160 protected String getGUID() { 161 if (GUID == null) { 162 GUID = ""; 163 String id = ""; 164 165 if (webApplication != null) { 166 id = webApplication.getContextRoot(); 167 } else { 168 id = contextPath; 169 } 170 171 if (id!=null) { 172 if (id.startsWith("/")) { 173 id = id.substring(id.indexOf("/")+1); 174 } 175 176 GUID += id; 177 } 178 } 179 180 return GUID; 181 } 182 183 private void setContextRoot(String contextRoot) { 184 if (contextRoot != null && contextRoot.endsWith(".war") ) { 186 this.contextPath = contextRoot.substring(0, contextRoot.length()-4); 187 } else { 188 this.contextPath = contextRoot; 189 } 190 } 191 192 194 public String getAppId() { 195 return appId; 196 } 197 198 public void setAppId(String appId) { 199 this.appId = appId; 200 } 201 202 public void setVersion(String version) { 203 this.version = version; 204 } 205 206 207 public Collection getCustomPortletMode() { 209 return customPortletMode; 210 } 211 212 public void setCustomPortletMode(Collection customPortletMode) { 213 this.customPortletMode = (ArrayList )customPortletMode; 214 } 215 216 public Collection getCustomPortletState() { 217 return customPortletState; 218 } 219 220 public void setCustomPortletState(Collection customPortletState) { 221 this.customPortletState = (ArrayList )customPortletState; 222 } 223 224 public Collection getUserAttribute() { 225 return userAttribute; 226 } 227 228 public void setUserAttribute(Collection userAttribute) { 229 this.userAttribute = (ArrayList )userAttribute; 230 } 231 232 public Collection getSecurityConstraint() { 233 return securityConstraint; 234 } 235 236 public void setSecurityConstraint(Collection securityConstraint) { 237 this.securityConstraint = (ArrayList )securityConstraint; 238 } 239 240 242 public Collection getCastorPortlets() { 243 return portlets; 244 } 245 246 protected void setWebApplicationDefinition(WebApplicationDefinition webApplication) { 247 this.webApplication = webApplication; 248 } 249 250 } 251 | Popular Tags |