1 16 package org.apache.cocoon.portal.wsrp.consumer; 17 18 import oasis.names.tc.wsrp.v1.types.RegistrationData; 19 20 import org.apache.avalon.framework.configuration.Configuration; 21 import org.apache.avalon.framework.configuration.ConfigurationException; 22 import org.apache.cocoon.portal.wsrp.adapter.WSRPAdapter; 23 import org.apache.wsrp4j.consumer.ConsumerEnvironment; 24 25 37 public class ProducerDescription { 38 39 40 protected String id; 41 42 43 protected String markupInterfaceUrl; 44 45 46 protected String serviceDescriptionInterfaceUrl; 47 48 49 protected String registrationInterfaceUrl; 50 51 52 protected String portletManagementInterfaceUrl; 53 54 55 protected String name; 56 57 58 protected String description; 59 60 61 protected RegistrationData registrationData; 62 63 66 public ProducerDescription() { 67 this(null); 68 } 69 70 75 public ProducerDescription(String id) { 76 this(id, null, null); 77 } 78 79 86 public ProducerDescription(String id, String markupUrl, String sdUrl) { 87 this(id, markupUrl, sdUrl, null, null); 88 } 89 90 99 public ProducerDescription(String id, 100 String markupUrl, 101 String sdUrl, 102 String regUrl, 103 String pmUrl) { 104 this.id = id; 105 this.markupInterfaceUrl = markupUrl; 106 this.serviceDescriptionInterfaceUrl = sdUrl; 107 this.registrationInterfaceUrl = regUrl; 108 this.portletManagementInterfaceUrl = pmUrl; 109 } 110 111 114 public String getId() { 115 return id; 116 } 117 118 123 public void setId(String id) { 124 this.id = id; 125 } 126 127 130 public String getMarkupInterfaceUrl() { 131 return markupInterfaceUrl; 132 } 133 134 139 public void setMarkupInterfaceUrl(String markupInterfaceUrl) { 140 this.markupInterfaceUrl = markupInterfaceUrl; 141 } 142 143 146 public String getPortletManagementInterfaceUrl() { 147 return portletManagementInterfaceUrl; 148 } 149 150 155 public void setPortletManagementInterfaceUrl(String portletManagementInterfaceUrl) { 156 this.portletManagementInterfaceUrl = portletManagementInterfaceUrl; 157 } 158 159 162 public String getRegistrationInterfaceUrl() { 163 return registrationInterfaceUrl; 164 } 165 166 171 public void setRegistrationInterfaceUrl(String registrationInterfaceUrl) { 172 this.registrationInterfaceUrl = registrationInterfaceUrl; 173 } 174 175 178 public String getServiceDescriptionInterfaceUrl() { 179 return serviceDescriptionInterfaceUrl; 180 } 181 182 187 public void setServiceDescriptionInterfaceUrl(String serviceDescriptionInterfaceUrl) { 188 this.serviceDescriptionInterfaceUrl = serviceDescriptionInterfaceUrl; 189 } 190 191 198 public static ProducerDescription fromConfiguration(Configuration config, ConsumerEnvironment env) 199 throws ConfigurationException { 200 final String producerId = config.getAttribute("id"); 201 final ProducerDescription desc = new ProducerDescription(producerId); 202 203 desc.setMarkupInterfaceUrl(config.getChild("markup-interface-url").getValue()); 204 desc.setServiceDescriptionInterfaceUrl(config.getChild("service-description-interface-url").getValue()); 205 desc.setRegistrationInterfaceUrl(config.getChild("registration-interface-url").getValue(null)); 206 desc.setPortletManagementInterfaceUrl(config.getChild("portlet-management-interface-url").getValue(null)); 207 boolean registrationRequired; 208 if ( desc.getRegistrationInterfaceUrl() != null ) { 209 registrationRequired = config.getChild("registration-interface-url").getAttributeAsBoolean("registration-required", true); 210 } else { 211 registrationRequired = false; 212 } 213 if ( registrationRequired == false ) { 214 desc.setRegistrationInterfaceUrl(null); 215 } else { 216 desc.setRegistrationData(createRegistrationData(config.getChild("registration-data"), env)); 218 } 219 220 desc.setName(config.getChild("name").getValue(null)); 222 desc.setDescription(config.getChild("description").getValue(null)); 223 224 return desc; 225 } 226 227 public static RegistrationData createRegistrationData(Configuration config, 228 ConsumerEnvironment env) { 229 RegistrationData registrationData = new RegistrationData( 230 env.getConsumerAgent(), 231 env.getSupportedModes(), 232 WSRPAdapter.CONSUMER_URL, null, env.getSupportedWindowStates(), 235 null, null, false, null ); 240 return registrationData; 241 } 242 243 246 public String getDescription() { 247 return description; 248 } 249 250 255 public void setDescription(String description) { 256 this.description = description; 257 } 258 259 262 public String getName() { 263 return name; 264 } 265 266 271 public void setName(String name) { 272 this.name = name; 273 } 274 275 public RegistrationData getRegistrationData() { 276 return registrationData; 277 } 278 279 public void setRegistrationData(RegistrationData registrationData) { 280 this.registrationData = registrationData; 281 } 282 } 283 | Popular Tags |