| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.apache.ws.scout.registry; |
| 18 | |
|
| 19 | |
import java.util.ArrayList; |
| 20 | |
import java.util.Collection; |
| 21 | |
import java.util.Locale; |
| 22 | |
|
| 23 | |
import javax.activation.DataHandler; |
| 24 | |
import javax.xml.registry.BulkResponse; |
| 25 | |
import javax.xml.registry.InvalidRequestException; |
| 26 | |
import javax.xml.registry.JAXRException; |
| 27 | |
import javax.xml.registry.LifeCycleManager; |
| 28 | |
import javax.xml.registry.RegistryService; |
| 29 | |
import javax.xml.registry.UnsupportedCapabilityException; |
| 30 | |
import javax.xml.registry.infomodel.Association; |
| 31 | |
import javax.xml.registry.infomodel.Classification; |
| 32 | |
import javax.xml.registry.infomodel.ClassificationScheme; |
| 33 | |
import javax.xml.registry.infomodel.Concept; |
| 34 | |
import javax.xml.registry.infomodel.EmailAddress; |
| 35 | |
import javax.xml.registry.infomodel.ExternalIdentifier; |
| 36 | |
import javax.xml.registry.infomodel.ExternalLink; |
| 37 | |
import javax.xml.registry.infomodel.ExtrinsicObject; |
| 38 | |
import javax.xml.registry.infomodel.InternationalString; |
| 39 | |
import javax.xml.registry.infomodel.Key; |
| 40 | |
import javax.xml.registry.infomodel.LocalizedString; |
| 41 | |
import javax.xml.registry.infomodel.Organization; |
| 42 | |
import javax.xml.registry.infomodel.PersonName; |
| 43 | |
import javax.xml.registry.infomodel.PostalAddress; |
| 44 | |
import javax.xml.registry.infomodel.RegistryObject; |
| 45 | |
import javax.xml.registry.infomodel.RegistryPackage; |
| 46 | |
import javax.xml.registry.infomodel.Service; |
| 47 | |
import javax.xml.registry.infomodel.ServiceBinding; |
| 48 | |
import javax.xml.registry.infomodel.Slot; |
| 49 | |
import javax.xml.registry.infomodel.SpecificationLink; |
| 50 | |
import javax.xml.registry.infomodel.TelephoneNumber; |
| 51 | |
import javax.xml.registry.infomodel.User; |
| 52 | |
|
| 53 | |
import org.apache.ws.scout.registry.infomodel.AssociationImpl; |
| 54 | |
import org.apache.ws.scout.registry.infomodel.ClassificationImpl; |
| 55 | |
import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl; |
| 56 | |
import org.apache.ws.scout.registry.infomodel.ConceptImpl; |
| 57 | |
import org.apache.ws.scout.registry.infomodel.EmailAddressImpl; |
| 58 | |
import org.apache.ws.scout.registry.infomodel.ExternalIdentifierImpl; |
| 59 | |
import org.apache.ws.scout.registry.infomodel.ExternalLinkImpl; |
| 60 | |
import org.apache.ws.scout.registry.infomodel.InternationalStringImpl; |
| 61 | |
import org.apache.ws.scout.registry.infomodel.KeyImpl; |
| 62 | |
import org.apache.ws.scout.registry.infomodel.LocalizedStringImpl; |
| 63 | |
import org.apache.ws.scout.registry.infomodel.OrganizationImpl; |
| 64 | |
import org.apache.ws.scout.registry.infomodel.PersonNameImpl; |
| 65 | |
import org.apache.ws.scout.registry.infomodel.PostalAddressImpl; |
| 66 | |
import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl; |
| 67 | |
import org.apache.ws.scout.registry.infomodel.ServiceImpl; |
| 68 | |
import org.apache.ws.scout.registry.infomodel.SlotImpl; |
| 69 | |
import org.apache.ws.scout.registry.infomodel.SpecificationLinkImpl; |
| 70 | |
import org.apache.ws.scout.registry.infomodel.TelephoneNumberImpl; |
| 71 | |
import org.apache.ws.scout.registry.infomodel.UserImpl; |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
public abstract class LifeCycleManagerImpl implements LifeCycleManager { |
| 81 | |
protected final RegistryServiceImpl registry; |
| 82 | |
|
| 83 | 246 | public LifeCycleManagerImpl(RegistryService registry) { |
| 84 | 246 | this.registry = (RegistryServiceImpl) registry; |
| 85 | 246 | } |
| 86 | |
|
| 87 | |
public RegistryService getRegistryService() { |
| 88 | 8 | return registry; |
| 89 | |
} |
| 90 | |
|
| 91 | |
public Object createObject(String interfaceName) throws JAXRException { |
| 92 | |
|
| 93 | |
|
| 94 | 238 | if (LifeCycleManager.ASSOCIATION.equals(interfaceName)) { |
| 95 | 8 | return new AssociationImpl(this); |
| 96 | |
} |
| 97 | 230 | else if (LifeCycleManager.AUDITABLE_EVENT.equals(interfaceName)) { |
| 98 | 2 | throw new UnsupportedCapabilityException(); |
| 99 | |
} |
| 100 | 228 | else if (LifeCycleManager.CLASSIFICATION.equals(interfaceName)) { |
| 101 | 20 | return new ClassificationImpl(this); |
| 102 | |
} |
| 103 | 208 | else if (LifeCycleManager.CLASSIFICATION_SCHEME.equals(interfaceName)) { |
| 104 | 2 | return new ClassificationSchemeImpl(this); |
| 105 | |
} |
| 106 | 206 | else if (LifeCycleManager.CONCEPT.equals(interfaceName)) { |
| 107 | 2 | return new ConceptImpl(this); |
| 108 | |
} |
| 109 | 204 | else if (LifeCycleManager.EMAIL_ADDRESS.equals(interfaceName)) { |
| 110 | 2 | return new EmailAddressImpl(); |
| 111 | |
} |
| 112 | 202 | else if (LifeCycleManager.EXTERNAL_IDENTIFIER.equals(interfaceName)) { |
| 113 | 2 | return new ExternalIdentifierImpl(this); |
| 114 | |
} |
| 115 | 200 | else if (LifeCycleManager.EXTERNAL_LINK.equals(interfaceName)) { |
| 116 | 2 | return new ExternalLinkImpl(this); |
| 117 | |
} |
| 118 | 198 | else if (LifeCycleManager.EXTRINSIC_OBJECT.equals(interfaceName)) { |
| 119 | 2 | throw new UnsupportedCapabilityException(); |
| 120 | |
} |
| 121 | 196 | else if (LifeCycleManager.INTERNATIONAL_STRING.equals(interfaceName)) { |
| 122 | 2 | return new InternationalStringImpl(); |
| 123 | |
} |
| 124 | 194 | else if (LifeCycleManager.KEY.equals(interfaceName)) { |
| 125 | 2 | return new KeyImpl(); |
| 126 | |
} |
| 127 | 192 | else if (LifeCycleManager.LOCALIZED_STRING.equals(interfaceName)) { |
| 128 | 2 | return new LocalizedStringImpl(); |
| 129 | |
} |
| 130 | 190 | else if (LifeCycleManager.ORGANIZATION.equals(interfaceName)) { |
| 131 | 40 | return new OrganizationImpl(this); |
| 132 | |
} |
| 133 | 150 | else if (LifeCycleManager.PERSON_NAME.equals(interfaceName)) { |
| 134 | 32 | return new PersonNameImpl(); |
| 135 | |
} |
| 136 | 118 | else if (LifeCycleManager.POSTAL_ADDRESS.equals(interfaceName)) { |
| 137 | 2 | return new PostalAddressImpl(registry.getDefaultPostalScheme()); |
| 138 | |
} |
| 139 | 116 | else if (LifeCycleManager.REGISTRY_ENTRY.equals(interfaceName)) { |
| 140 | 2 | throw new UnsupportedCapabilityException(); |
| 141 | |
} |
| 142 | 114 | else if (LifeCycleManager.REGISTRY_PACKAGE.equals(interfaceName)) { |
| 143 | 2 | throw new UnsupportedCapabilityException(); |
| 144 | |
} |
| 145 | 112 | else if (LifeCycleManager.SERVICE.equals(interfaceName)) { |
| 146 | 22 | return new ServiceImpl(this); |
| 147 | |
} |
| 148 | 90 | else if (LifeCycleManager.SERVICE_BINDING.equals(interfaceName)) { |
| 149 | 16 | return new ServiceBindingImpl(this); |
| 150 | |
} |
| 151 | 74 | else if (LifeCycleManager.SLOT.equals(interfaceName)) { |
| 152 | 2 | return new SlotImpl(); |
| 153 | |
} |
| 154 | 72 | else if (LifeCycleManager.SPECIFICATION_LINK.equals(interfaceName)) { |
| 155 | 6 | return new SpecificationLinkImpl(this); |
| 156 | |
} |
| 157 | 66 | else if (LifeCycleManager.TELEPHONE_NUMBER.equals(interfaceName)) { |
| 158 | 32 | return new TelephoneNumberImpl(); |
| 159 | |
} |
| 160 | 34 | else if (LifeCycleManager.USER.equals(interfaceName)) { |
| 161 | 32 | return new UserImpl(this); |
| 162 | |
} |
| 163 | 2 | else if (LifeCycleManager.VERSIONABLE.equals(interfaceName)) { |
| 164 | 0 | throw new UnsupportedCapabilityException(); |
| 165 | |
} |
| 166 | |
else { |
| 167 | 2 | throw new InvalidRequestException("Unknown interface: " + interfaceName); |
| 168 | |
} |
| 169 | |
} |
| 170 | |
|
| 171 | |
public Association createAssociation(RegistryObject targetObject, Concept associationType) throws JAXRException { |
| 172 | 6 | Association assoc = (Association) this.createObject(LifeCycleManager.ASSOCIATION); |
| 173 | 6 | assoc.setTargetObject(targetObject); |
| 174 | 6 | assoc.setAssociationType(associationType); |
| 175 | 6 | return assoc; |
| 176 | |
} |
| 177 | |
|
| 178 | |
public Classification createClassification(Concept concept) throws JAXRException, InvalidRequestException { |
| 179 | 0 | if (concept.getClassificationScheme() == null) { |
| 180 | 0 | throw new InvalidRequestException("Concept is not under classification scheme"); |
| 181 | |
} |
| 182 | 0 | Classification classify = (Classification) this.createObject(LifeCycleManager.CLASSIFICATION); |
| 183 | 0 | classify.setConcept(concept); |
| 184 | 0 | return classify; |
| 185 | |
} |
| 186 | |
|
| 187 | |
public Classification createClassification(ClassificationScheme scheme, |
| 188 | |
InternationalString name, |
| 189 | |
String value) throws JAXRException { |
| 190 | 18 | Classification cl = (Classification) this.createObject(LifeCycleManager.CLASSIFICATION); |
| 191 | 18 | cl.setClassificationScheme(scheme); |
| 192 | 18 | cl.setName(name); |
| 193 | 18 | cl.setValue(value); |
| 194 | |
|
| 195 | 18 | ((ClassificationImpl) cl).setExternal(true); |
| 196 | |
|
| 197 | 18 | return cl; |
| 198 | |
} |
| 199 | |
|
| 200 | |
public Classification createClassification(ClassificationScheme scheme, |
| 201 | |
String name, String value) |
| 202 | |
throws JAXRException { |
| 203 | 18 | return createClassification(scheme, this.createInternationalString(name), value); |
| 204 | |
} |
| 205 | |
|
| 206 | |
public ClassificationScheme createClassificationScheme(Concept concept) throws JAXRException, InvalidRequestException { |
| 207 | |
|
| 208 | 0 | if (concept.getParentConcept() != null || concept.getClassificationScheme() != null) { |
| 209 | 0 | throw new InvalidRequestException("Concept has classificationscheme or has a parent"); |
| 210 | |
} |
| 211 | |
|
| 212 | |
|
| 213 | 0 | ClassificationScheme cs = new ClassificationSchemeImpl(this); |
| 214 | 0 | cs.addChildConcept(concept); |
| 215 | 0 | return cs; |
| 216 | |
} |
| 217 | |
|
| 218 | |
public ClassificationScheme createClassificationScheme(InternationalString name, |
| 219 | |
InternationalString des) |
| 220 | |
throws JAXRException, InvalidRequestException { |
| 221 | 32 | ClassificationScheme cs = new ClassificationSchemeImpl(this); |
| 222 | 32 | cs.setName(name); |
| 223 | 32 | cs.setDescription(des); |
| 224 | 32 | return cs; |
| 225 | |
} |
| 226 | |
|
| 227 | |
public ClassificationScheme createClassificationScheme(String name, String desc) |
| 228 | |
throws JAXRException, InvalidRequestException { |
| 229 | 56 | return createClassificationScheme(this.createInternationalString(name), |
| 230 | 28 | this.createInternationalString(desc)); |
| 231 | |
} |
| 232 | |
|
| 233 | |
public Concept createConcept(RegistryObject parent, InternationalString name, String value) |
| 234 | |
throws JAXRException { |
| 235 | 4 | ConceptImpl concept = new ConceptImpl(this); |
| 236 | 4 | concept.setClassificationScheme((ClassificationScheme) parent); |
| 237 | 4 | concept.setParent(parent); |
| 238 | 4 | concept.setName(name); |
| 239 | 4 | concept.setValue(value); |
| 240 | 4 | return concept; |
| 241 | |
} |
| 242 | |
|
| 243 | |
public Concept createConcept(RegistryObject parent, String name, String value) throws JAXRException { |
| 244 | 4 | return createConcept(parent, this.createInternationalString(name), value); |
| 245 | |
} |
| 246 | |
|
| 247 | |
public EmailAddress createEmailAddress(String address) throws JAXRException { |
| 248 | 30 | return new EmailAddressImpl(address); |
| 249 | |
} |
| 250 | |
|
| 251 | |
public EmailAddress createEmailAddress(String address, String type) throws JAXRException { |
| 252 | 0 | return new EmailAddressImpl(address, type); |
| 253 | |
} |
| 254 | |
|
| 255 | |
public ExternalIdentifier createExternalIdentifier(ClassificationScheme ids, |
| 256 | |
InternationalString name, |
| 257 | |
String value) throws JAXRException { |
| 258 | 0 | return new ExternalIdentifierImpl(this, ids, name, value); |
| 259 | |
} |
| 260 | |
|
| 261 | |
public ExternalIdentifier createExternalIdentifier(ClassificationScheme ids, |
| 262 | |
String name, String value) throws JAXRException { |
| 263 | 0 | return createExternalIdentifier(ids, this.createInternationalString(name), value); |
| 264 | |
} |
| 265 | |
|
| 266 | |
public ExternalLink createExternalLink(String uri, InternationalString desc) throws JAXRException { |
| 267 | 8 | ExternalLink ext = new ExternalLinkImpl(this); |
| 268 | 8 | ext.setExternalURI(uri); |
| 269 | 8 | ext.setDescription(desc); |
| 270 | 8 | return ext; |
| 271 | |
} |
| 272 | |
|
| 273 | |
public ExternalLink createExternalLink(String uri, String desc) throws JAXRException { |
| 274 | 8 | return createExternalLink(uri, createInternationalString(desc)); |
| 275 | |
} |
| 276 | |
|
| 277 | |
public InternationalString createInternationalString() throws JAXRException { |
| 278 | 0 | return new InternationalStringImpl(); |
| 279 | |
} |
| 280 | |
|
| 281 | |
public InternationalString createInternationalString(String value) throws JAXRException { |
| 282 | 232 | return new InternationalStringImpl(Locale.getDefault(), value, LocalizedString.DEFAULT_CHARSET_NAME); |
| 283 | |
} |
| 284 | |
|
| 285 | |
public InternationalString createInternationalString(Locale locale, String value) throws JAXRException { |
| 286 | 241 | return new InternationalStringImpl(locale, value, LocalizedString.DEFAULT_CHARSET_NAME); |
| 287 | |
} |
| 288 | |
|
| 289 | |
public Key createKey(String id) { |
| 290 | 177 | return new KeyImpl(id); |
| 291 | |
} |
| 292 | |
|
| 293 | |
public LocalizedString createLocalizedString(Locale locale, String value) throws JAXRException { |
| 294 | 0 | return new LocalizedStringImpl(locale, value, LocalizedString.DEFAULT_CHARSET_NAME); |
| 295 | |
} |
| 296 | |
|
| 297 | |
public LocalizedString createLocalizedString(Locale locale, String value, String charsetName) throws JAXRException { |
| 298 | 0 | return new LocalizedStringImpl(locale, value, charsetName); |
| 299 | |
} |
| 300 | |
|
| 301 | |
public Organization createOrganization(InternationalString name) throws JAXRException { |
| 302 | 36 | Organization org = (Organization) this.createObject(LifeCycleManager.ORGANIZATION); |
| 303 | 36 | org.setName(name); |
| 304 | 36 | return org; |
| 305 | |
} |
| 306 | |
|
| 307 | |
public Organization createOrganization(String name) throws JAXRException { |
| 308 | 0 | Organization org = (Organization) this.createObject(LifeCycleManager.ORGANIZATION); |
| 309 | 0 | org.setName(this.createInternationalString(name)); |
| 310 | 0 | return org; |
| 311 | |
} |
| 312 | |
|
| 313 | |
public PersonName createPersonName(String fullName) throws JAXRException { |
| 314 | 30 | PersonName pn = (PersonName) this.createObject(LifeCycleManager.PERSON_NAME); |
| 315 | 30 | pn.setFullName(fullName); |
| 316 | 30 | return pn; |
| 317 | |
} |
| 318 | |
|
| 319 | |
public PostalAddress createPostalAddress(String streetNumber, |
| 320 | |
String street, |
| 321 | |
String city, |
| 322 | |
String stateOrProvince, |
| 323 | |
String country, |
| 324 | |
String postalCode, String type) throws JAXRException { |
| 325 | 30 | PostalAddress post = new PostalAddressImpl(); |
| 326 | 30 | post.setStreetNumber(streetNumber); |
| 327 | 30 | post.setStreet(street); |
| 328 | 30 | post.setCity(city); |
| 329 | 30 | post.setStateOrProvince(stateOrProvince); |
| 330 | 30 | post.setCountry(country); |
| 331 | 30 | post.setPostalCode(postalCode); |
| 332 | 30 | post.setType(type); |
| 333 | 30 | return post; |
| 334 | |
} |
| 335 | |
|
| 336 | |
public Service createService(InternationalString name) throws JAXRException { |
| 337 | 18 | Service ser = (Service) this.createObject(LifeCycleManager.SERVICE); |
| 338 | 18 | ser.setName(name); |
| 339 | 18 | return ser; |
| 340 | |
} |
| 341 | |
|
| 342 | |
public Service createService(String name) throws JAXRException { |
| 343 | 0 | return createService(this.createInternationalString(name)); |
| 344 | |
} |
| 345 | |
|
| 346 | |
public ServiceBinding createServiceBinding() throws JAXRException { |
| 347 | 14 | return (ServiceBinding) this.createObject(LifeCycleManager.SERVICE_BINDING); |
| 348 | |
} |
| 349 | |
|
| 350 | |
public Slot createSlot(String name, String value, String slotType) throws JAXRException { |
| 351 | 0 | Collection<String> col = new ArrayList<String>(); |
| 352 | 0 | col.add(value); |
| 353 | 0 | Slot slot = (Slot) this.createObject(LifeCycleManager.SLOT); |
| 354 | 0 | slot.setName(name); |
| 355 | 0 | slot.setValues(col); |
| 356 | 0 | slot.setSlotType(slotType); |
| 357 | 0 | return slot; |
| 358 | |
} |
| 359 | |
|
| 360 | |
public Slot createSlot(String name, Collection values, String slotType) throws JAXRException { |
| 361 | 0 | Slot slot = (Slot) this.createObject(LifeCycleManager.SLOT); |
| 362 | 0 | slot.setName(name); |
| 363 | 0 | slot.setValues(values); |
| 364 | 0 | slot.setSlotType(slotType); |
| 365 | 0 | return slot; |
| 366 | |
} |
| 367 | |
|
| 368 | |
public SpecificationLink createSpecificationLink() throws JAXRException { |
| 369 | 4 | return (SpecificationLink) this.createObject(LifeCycleManager.SPECIFICATION_LINK); |
| 370 | |
} |
| 371 | |
|
| 372 | |
public TelephoneNumber createTelephoneNumber() throws JAXRException { |
| 373 | 30 | return (TelephoneNumber) this.createObject(LifeCycleManager.TELEPHONE_NUMBER); |
| 374 | |
} |
| 375 | |
|
| 376 | |
public User createUser() throws JAXRException { |
| 377 | 30 | return (User) this.createObject(LifeCycleManager.USER); |
| 378 | |
} |
| 379 | |
|
| 380 | |
|
| 381 | |
|
| 382 | |
|
| 383 | |
|
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | |
|
| 391 | |
|
| 392 | |
|
| 393 | |
|
| 394 | |
public abstract BulkResponse saveObjects(Collection objects) throws JAXRException; |
| 395 | |
|
| 396 | |
|
| 397 | |
|
| 398 | |
|
| 399 | |
|
| 400 | |
|
| 401 | |
|
| 402 | |
|
| 403 | |
|
| 404 | |
|
| 405 | |
public abstract BulkResponse deleteObjects(Collection keys, String objectType) throws JAXRException; |
| 406 | |
|
| 407 | |
|
| 408 | |
|
| 409 | |
|
| 410 | |
|
| 411 | |
|
| 412 | |
|
| 413 | |
|
| 414 | |
|
| 415 | |
|
| 416 | |
|
| 417 | |
public ExtrinsicObject createExtrinsicObject(DataHandler repositoryItem) throws JAXRException { |
| 418 | 0 | throw new UnsupportedCapabilityException(); |
| 419 | |
} |
| 420 | |
|
| 421 | |
public PersonName createPersonName(String firstName, String middleName, String lastName) throws JAXRException { |
| 422 | 0 | throw new UnsupportedCapabilityException(); |
| 423 | |
} |
| 424 | |
|
| 425 | |
public RegistryPackage createRegistryPackage(InternationalString name) throws JAXRException { |
| 426 | 2 | throw new UnsupportedCapabilityException(); |
| 427 | |
} |
| 428 | |
|
| 429 | |
public RegistryPackage createRegistryPackage(String name) throws JAXRException { |
| 430 | 2 | throw new UnsupportedCapabilityException(); |
| 431 | |
} |
| 432 | |
|
| 433 | |
public BulkResponse deprecateObjects(Collection keys) throws JAXRException { |
| 434 | 2 | throw new UnsupportedCapabilityException(); |
| 435 | |
} |
| 436 | |
|
| 437 | |
public BulkResponse unDeprecateObjects(Collection keys) throws JAXRException { |
| 438 | 2 | throw new UnsupportedCapabilityException(); |
| 439 | |
} |
| 440 | |
|
| 441 | |
public BulkResponse deleteObjects(Collection keys) throws JAXRException { |
| 442 | 0 | throw new UnsupportedCapabilityException(); |
| 443 | |
} |
| 444 | |
|
| 445 | |
} |