This project has retired. For details please refer to its
Attic page.
LifeCycleManagerImpl xref
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 public LifeCycleManagerImpl(RegistryService registry) {
84 this.registry = (RegistryServiceImpl) registry;
85 }
86
87 public RegistryService getRegistryService() {
88 return registry;
89 }
90
91 public Object createObject(String interfaceName) throws JAXRException {
92
93
94 if (LifeCycleManager.ASSOCIATION.equals(interfaceName)) {
95 return new AssociationImpl(this);
96 }
97 else if (LifeCycleManager.AUDITABLE_EVENT.equals(interfaceName)) {
98 throw new UnsupportedCapabilityException();
99 }
100 else if (LifeCycleManager.CLASSIFICATION.equals(interfaceName)) {
101 return new ClassificationImpl(this);
102 }
103 else if (LifeCycleManager.CLASSIFICATION_SCHEME.equals(interfaceName)) {
104 return new ClassificationSchemeImpl(this);
105 }
106 else if (LifeCycleManager.CONCEPT.equals(interfaceName)) {
107 return new ConceptImpl(this);
108 }
109 else if (LifeCycleManager.EMAIL_ADDRESS.equals(interfaceName)) {
110 return new EmailAddressImpl();
111 }
112 else if (LifeCycleManager.EXTERNAL_IDENTIFIER.equals(interfaceName)) {
113 return new ExternalIdentifierImpl(this);
114 }
115 else if (LifeCycleManager.EXTERNAL_LINK.equals(interfaceName)) {
116 return new ExternalLinkImpl(this);
117 }
118 else if (LifeCycleManager.EXTRINSIC_OBJECT.equals(interfaceName)) {
119 throw new UnsupportedCapabilityException();
120 }
121 else if (LifeCycleManager.INTERNATIONAL_STRING.equals(interfaceName)) {
122 return new InternationalStringImpl();
123 }
124 else if (LifeCycleManager.KEY.equals(interfaceName)) {
125 return new KeyImpl();
126 }
127 else if (LifeCycleManager.LOCALIZED_STRING.equals(interfaceName)) {
128 return new LocalizedStringImpl();
129 }
130 else if (LifeCycleManager.ORGANIZATION.equals(interfaceName)) {
131 return new OrganizationImpl(this);
132 }
133 else if (LifeCycleManager.PERSON_NAME.equals(interfaceName)) {
134 return new PersonNameImpl();
135 }
136 else if (LifeCycleManager.POSTAL_ADDRESS.equals(interfaceName)) {
137 return new PostalAddressImpl(registry.getDefaultPostalScheme());
138 }
139 else if (LifeCycleManager.REGISTRY_ENTRY.equals(interfaceName)) {
140 throw new UnsupportedCapabilityException();
141 }
142 else if (LifeCycleManager.REGISTRY_PACKAGE.equals(interfaceName)) {
143 throw new UnsupportedCapabilityException();
144 }
145 else if (LifeCycleManager.SERVICE.equals(interfaceName)) {
146 return new ServiceImpl(this);
147 }
148 else if (LifeCycleManager.SERVICE_BINDING.equals(interfaceName)) {
149 return new ServiceBindingImpl(this);
150 }
151 else if (LifeCycleManager.SLOT.equals(interfaceName)) {
152 return new SlotImpl();
153 }
154 else if (LifeCycleManager.SPECIFICATION_LINK.equals(interfaceName)) {
155 return new SpecificationLinkImpl(this);
156 }
157 else if (LifeCycleManager.TELEPHONE_NUMBER.equals(interfaceName)) {
158 return new TelephoneNumberImpl();
159 }
160 else if (LifeCycleManager.USER.equals(interfaceName)) {
161 return new UserImpl(this);
162 }
163 else if (LifeCycleManager.VERSIONABLE.equals(interfaceName)) {
164 throw new UnsupportedCapabilityException();
165 }
166 else {
167 throw new InvalidRequestException("Unknown interface: " + interfaceName);
168 }
169 }
170
171 public Association createAssociation(RegistryObject targetObject, Concept associationType) throws JAXRException {
172 Association assoc = (Association) this.createObject(LifeCycleManager.ASSOCIATION);
173 assoc.setTargetObject(targetObject);
174 assoc.setAssociationType(associationType);
175 return assoc;
176 }
177
178 public Classification createClassification(Concept concept) throws JAXRException, InvalidRequestException {
179 if (concept.getClassificationScheme() == null) {
180 throw new InvalidRequestException("Concept is not under classification scheme");
181 }
182 Classification classify = (Classification) this.createObject(LifeCycleManager.CLASSIFICATION);
183 classify.setConcept(concept);
184 return classify;
185 }
186
187 public Classification createClassification(ClassificationScheme scheme,
188 InternationalString name,
189 String value) throws JAXRException {
190 Classification cl = (Classification) this.createObject(LifeCycleManager.CLASSIFICATION);
191 cl.setClassificationScheme(scheme);
192 cl.setName(name);
193 cl.setValue(value);
194
195 ((ClassificationImpl) cl).setExternal(true);
196
197 return cl;
198 }
199
200 public Classification createClassification(ClassificationScheme scheme,
201 String name, String value)
202 throws JAXRException {
203 return createClassification(scheme, this.createInternationalString(name), value);
204 }
205
206 public ClassificationScheme createClassificationScheme(Concept concept) throws JAXRException, InvalidRequestException {
207
208 if (concept.getParentConcept() != null || concept.getClassificationScheme() != null) {
209 throw new InvalidRequestException("Concept has classificationscheme or has a parent");
210 }
211
212
213 ClassificationScheme cs = new ClassificationSchemeImpl(this);
214 cs.addChildConcept(concept);
215 return cs;
216 }
217
218 public ClassificationScheme createClassificationScheme(InternationalString name,
219 InternationalString des)
220 throws JAXRException, InvalidRequestException {
221 ClassificationScheme cs = new ClassificationSchemeImpl(this);
222 cs.setName(name);
223 cs.setDescription(des);
224 return cs;
225 }
226
227 public ClassificationScheme createClassificationScheme(String name, String desc)
228 throws JAXRException, InvalidRequestException {
229 return createClassificationScheme(this.createInternationalString(name),
230 this.createInternationalString(desc));
231 }
232
233 public Concept createConcept(RegistryObject parent, InternationalString name, String value)
234 throws JAXRException {
235 ConceptImplfomodel/ConceptImpl.html#ConceptImpl">ConceptImpl concept = new ConceptImpl(this);
236 concept.setClassificationScheme((ClassificationScheme) parent);
237 concept.setParent(parent);
238 concept.setName(name);
239 concept.setValue(value);
240 return concept;
241 }
242
243 public Concept createConcept(RegistryObject parent, String name, String value) throws JAXRException {
244 return createConcept(parent, this.createInternationalString(name), value);
245 }
246
247 public EmailAddress createEmailAddress(String address) throws JAXRException {
248 return new EmailAddressImpl(address);
249 }
250
251 public EmailAddress createEmailAddress(String address, String type) throws JAXRException {
252 return new EmailAddressImpl(address, type);
253 }
254
255 public ExternalIdentifier createExternalIdentifier(ClassificationScheme ids,
256 InternationalString name,
257 String value) throws JAXRException {
258 return new ExternalIdentifierImpl(this, ids, name, value);
259 }
260
261 public ExternalIdentifier createExternalIdentifier(ClassificationScheme ids,
262 String name, String value) throws JAXRException {
263 return createExternalIdentifier(ids, this.createInternationalString(name), value);
264 }
265
266 public ExternalLink createExternalLink(String uri, InternationalString desc) throws JAXRException {
267 ExternalLink ext = new ExternalLinkImpl(this);
268 ext.setExternalURI(uri);
269 ext.setDescription(desc);
270 return ext;
271 }
272
273 public ExternalLink createExternalLink(String uri, String desc) throws JAXRException {
274 return createExternalLink(uri, createInternationalString(desc));
275 }
276
277 public InternationalString createInternationalString() throws JAXRException {
278 return new InternationalStringImpl();
279 }
280
281 public InternationalString createInternationalString(String value) throws JAXRException {
282 return new InternationalStringImpl(Locale.getDefault(), value, LocalizedString.DEFAULT_CHARSET_NAME);
283 }
284
285 public InternationalString createInternationalString(Locale locale, String value) throws JAXRException {
286 return new InternationalStringImpl(locale, value, LocalizedString.DEFAULT_CHARSET_NAME);
287 }
288
289 public Key createKey(String id) {
290 return new KeyImpl(id);
291 }
292
293 public LocalizedString createLocalizedString(Locale locale, String value) throws JAXRException {
294 return new LocalizedStringImpl(locale, value, LocalizedString.DEFAULT_CHARSET_NAME);
295 }
296
297 public LocalizedString createLocalizedString(Locale locale, String value, String charsetName) throws JAXRException {
298 return new LocalizedStringImpl(locale, value, charsetName);
299 }
300
301 public Organization createOrganization(InternationalString name) throws JAXRException {
302 Organization org = (Organization) this.createObject(LifeCycleManager.ORGANIZATION);
303 org.setName(name);
304 return org;
305 }
306
307 public Organization createOrganization(String name) throws JAXRException {
308 Organization org = (Organization) this.createObject(LifeCycleManager.ORGANIZATION);
309 org.setName(this.createInternationalString(name));
310 return org;
311 }
312
313 public PersonName createPersonName(String fullName) throws JAXRException {
314 PersonName pn = (PersonName) this.createObject(LifeCycleManager.PERSON_NAME);
315 pn.setFullName(fullName);
316 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 PostalAddress post = new PostalAddressImpl();
326 post.setStreetNumber(streetNumber);
327 post.setStreet(street);
328 post.setCity(city);
329 post.setStateOrProvince(stateOrProvince);
330 post.setCountry(country);
331 post.setPostalCode(postalCode);
332 post.setType(type);
333 return post;
334 }
335
336 public Service createService(InternationalString name) throws JAXRException {
337 Service ser = (Service) this.createObject(LifeCycleManager.SERVICE);
338 ser.setName(name);
339 return ser;
340 }
341
342 public Service createService(String name) throws JAXRException {
343 return createService(this.createInternationalString(name));
344 }
345
346 public ServiceBinding createServiceBinding() throws JAXRException {
347 return (ServiceBinding) this.createObject(LifeCycleManager.SERVICE_BINDING);
348 }
349
350 public Slot createSlot(String name, String value, String slotType) throws JAXRException {
351 Collection<String> col = new ArrayList<String>();
352 col.add(value);
353 Slot slot = (Slot) this.createObject(LifeCycleManager.SLOT);
354 slot.setName(name);
355 slot.setValues(col);
356 slot.setSlotType(slotType);
357 return slot;
358 }
359
360 public Slot createSlot(String name, Collection values, String slotType) throws JAXRException {
361 Slot slot = (Slot) this.createObject(LifeCycleManager.SLOT);
362 slot.setName(name);
363 slot.setValues(values);
364 slot.setSlotType(slotType);
365 return slot;
366 }
367
368 public SpecificationLink createSpecificationLink() throws JAXRException {
369 return (SpecificationLink) this.createObject(LifeCycleManager.SPECIFICATION_LINK);
370 }
371
372 public TelephoneNumber createTelephoneNumber() throws JAXRException {
373 return (TelephoneNumber) this.createObject(LifeCycleManager.TELEPHONE_NUMBER);
374 }
375
376 public User createUser() throws JAXRException {
377 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 throw new UnsupportedCapabilityException();
419 }
420
421 public PersonName createPersonName(String firstName, String middleName, String lastName) throws JAXRException {
422 throw new UnsupportedCapabilityException();
423 }
424
425 public RegistryPackage createRegistryPackage(InternationalString name) throws JAXRException {
426 throw new UnsupportedCapabilityException();
427 }
428
429 public RegistryPackage createRegistryPackage(String name) throws JAXRException {
430 throw new UnsupportedCapabilityException();
431 }
432
433 public BulkResponse deprecateObjects(Collection keys) throws JAXRException {
434 throw new UnsupportedCapabilityException();
435 }
436
437 public BulkResponse unDeprecateObjects(Collection keys) throws JAXRException {
438 throw new UnsupportedCapabilityException();
439 }
440
441 public BulkResponse deleteObjects(Collection keys) throws JAXRException {
442 throw new UnsupportedCapabilityException();
443 }
444
445 }