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 | 0 | public LifeCycleManagerImpl(RegistryService registry) { |
84 | 0 | this.registry = (RegistryServiceImpl) registry; |
85 | 0 | } |
86 | |
|
87 | |
public RegistryService getRegistryService() { |
88 | 0 | return registry; |
89 | |
} |
90 | |
|
91 | |
public Object createObject(String interfaceName) throws JAXRException { |
92 | |
|
93 | |
|
94 | 0 | if (LifeCycleManager.ASSOCIATION.equals(interfaceName)) { |
95 | 0 | return new AssociationImpl(this); |
96 | |
} |
97 | 0 | else if (LifeCycleManager.AUDITABLE_EVENT.equals(interfaceName)) { |
98 | 0 | throw new UnsupportedCapabilityException(); |
99 | |
} |
100 | 0 | else if (LifeCycleManager.CLASSIFICATION.equals(interfaceName)) { |
101 | 0 | return new ClassificationImpl(this); |
102 | |
} |
103 | 0 | else if (LifeCycleManager.CLASSIFICATION_SCHEME.equals(interfaceName)) { |
104 | 0 | return new ClassificationSchemeImpl(this); |
105 | |
} |
106 | 0 | else if (LifeCycleManager.CONCEPT.equals(interfaceName)) { |
107 | 0 | return new ConceptImpl(this); |
108 | |
} |
109 | 0 | else if (LifeCycleManager.EMAIL_ADDRESS.equals(interfaceName)) { |
110 | 0 | return new EmailAddressImpl(); |
111 | |
} |
112 | 0 | else if (LifeCycleManager.EXTERNAL_IDENTIFIER.equals(interfaceName)) { |
113 | 0 | return new ExternalIdentifierImpl(this); |
114 | |
} |
115 | 0 | else if (LifeCycleManager.EXTERNAL_LINK.equals(interfaceName)) { |
116 | 0 | return new ExternalLinkImpl(this); |
117 | |
} |
118 | 0 | else if (LifeCycleManager.EXTRINSIC_OBJECT.equals(interfaceName)) { |
119 | 0 | throw new UnsupportedCapabilityException(); |
120 | |
} |
121 | 0 | else if (LifeCycleManager.INTERNATIONAL_STRING.equals(interfaceName)) { |
122 | 0 | return new InternationalStringImpl(); |
123 | |
} |
124 | 0 | else if (LifeCycleManager.KEY.equals(interfaceName)) { |
125 | 0 | return new KeyImpl(); |
126 | |
} |
127 | 0 | else if (LifeCycleManager.LOCALIZED_STRING.equals(interfaceName)) { |
128 | 0 | return new LocalizedStringImpl(); |
129 | |
} |
130 | 0 | else if (LifeCycleManager.ORGANIZATION.equals(interfaceName)) { |
131 | 0 | return new OrganizationImpl(this); |
132 | |
} |
133 | 0 | else if (LifeCycleManager.PERSON_NAME.equals(interfaceName)) { |
134 | 0 | return new PersonNameImpl(); |
135 | |
} |
136 | 0 | else if (LifeCycleManager.POSTAL_ADDRESS.equals(interfaceName)) { |
137 | 0 | return new PostalAddressImpl(registry.getDefaultPostalScheme()); |
138 | |
} |
139 | 0 | else if (LifeCycleManager.REGISTRY_ENTRY.equals(interfaceName)) { |
140 | 0 | throw new UnsupportedCapabilityException(); |
141 | |
} |
142 | 0 | else if (LifeCycleManager.REGISTRY_PACKAGE.equals(interfaceName)) { |
143 | 0 | throw new UnsupportedCapabilityException(); |
144 | |
} |
145 | 0 | else if (LifeCycleManager.SERVICE.equals(interfaceName)) { |
146 | 0 | return new ServiceImpl(this); |
147 | |
} |
148 | 0 | else if (LifeCycleManager.SERVICE_BINDING.equals(interfaceName)) { |
149 | 0 | return new ServiceBindingImpl(this); |
150 | |
} |
151 | 0 | else if (LifeCycleManager.SLOT.equals(interfaceName)) { |
152 | 0 | return new SlotImpl(); |
153 | |
} |
154 | 0 | else if (LifeCycleManager.SPECIFICATION_LINK.equals(interfaceName)) { |
155 | 0 | return new SpecificationLinkImpl(this); |
156 | |
} |
157 | 0 | else if (LifeCycleManager.TELEPHONE_NUMBER.equals(interfaceName)) { |
158 | 0 | return new TelephoneNumberImpl(); |
159 | |
} |
160 | 0 | else if (LifeCycleManager.USER.equals(interfaceName)) { |
161 | 0 | return new UserImpl(this); |
162 | |
} |
163 | 0 | else if (LifeCycleManager.VERSIONABLE.equals(interfaceName)) { |
164 | 0 | throw new UnsupportedCapabilityException(); |
165 | |
} |
166 | |
else { |
167 | 0 | throw new InvalidRequestException("Unknown interface: " + interfaceName); |
168 | |
} |
169 | |
} |
170 | |
|
171 | |
public Association createAssociation(RegistryObject targetObject, Concept associationType) throws JAXRException { |
172 | 0 | Association assoc = (Association) this.createObject(LifeCycleManager.ASSOCIATION); |
173 | 0 | assoc.setTargetObject(targetObject); |
174 | 0 | assoc.setAssociationType(associationType); |
175 | 0 | 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 | 0 | Classification cl = (Classification) this.createObject(LifeCycleManager.CLASSIFICATION); |
191 | 0 | cl.setClassificationScheme(scheme); |
192 | 0 | cl.setName(name); |
193 | 0 | cl.setValue(value); |
194 | |
|
195 | 0 | ((ClassificationImpl) cl).setExternal(true); |
196 | |
|
197 | 0 | return cl; |
198 | |
} |
199 | |
|
200 | |
public Classification createClassification(ClassificationScheme scheme, |
201 | |
String name, String value) |
202 | |
throws JAXRException { |
203 | 0 | 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 | 0 | ClassificationScheme cs = new ClassificationSchemeImpl(this); |
222 | 0 | cs.setName(name); |
223 | 0 | cs.setDescription(des); |
224 | 0 | return cs; |
225 | |
} |
226 | |
|
227 | |
public ClassificationScheme createClassificationScheme(String name, String desc) |
228 | |
throws JAXRException, InvalidRequestException { |
229 | 0 | 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 | 0 | ConceptImpl concept = new ConceptImpl(this); |
236 | 0 | concept.setClassificationScheme((ClassificationScheme) parent); |
237 | 0 | concept.setParent(parent); |
238 | 0 | concept.setName(name); |
239 | 0 | concept.setValue(value); |
240 | 0 | return concept; |
241 | |
} |
242 | |
|
243 | |
public Concept createConcept(RegistryObject parent, String name, String value) throws JAXRException { |
244 | 0 | return createConcept(parent, this.createInternationalString(name), value); |
245 | |
} |
246 | |
|
247 | |
public EmailAddress createEmailAddress(String address) throws JAXRException { |
248 | 0 | 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 | 0 | ExternalLink ext = new ExternalLinkImpl(this); |
268 | 0 | ext.setExternalURI(uri); |
269 | 0 | ext.setDescription(desc); |
270 | 0 | return ext; |
271 | |
} |
272 | |
|
273 | |
public ExternalLink createExternalLink(String uri, String desc) throws JAXRException { |
274 | 0 | 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 | 0 | return new InternationalStringImpl(Locale.getDefault(), value, LocalizedString.DEFAULT_CHARSET_NAME); |
283 | |
} |
284 | |
|
285 | |
public InternationalString createInternationalString(Locale locale, String value) throws JAXRException { |
286 | 0 | return new InternationalStringImpl(locale, value, LocalizedString.DEFAULT_CHARSET_NAME); |
287 | |
} |
288 | |
|
289 | |
public Key createKey(String id) { |
290 | 0 | 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 | 0 | Organization org = (Organization) this.createObject(LifeCycleManager.ORGANIZATION); |
303 | 0 | org.setName(name); |
304 | 0 | 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 | 0 | PersonName pn = (PersonName) this.createObject(LifeCycleManager.PERSON_NAME); |
315 | 0 | pn.setFullName(fullName); |
316 | 0 | 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 | 0 | PostalAddress post = new PostalAddressImpl(); |
326 | 0 | post.setStreetNumber(streetNumber); |
327 | 0 | post.setStreet(street); |
328 | 0 | post.setCity(city); |
329 | 0 | post.setStateOrProvince(stateOrProvince); |
330 | 0 | post.setCountry(country); |
331 | 0 | post.setPostalCode(postalCode); |
332 | 0 | post.setType(type); |
333 | 0 | return post; |
334 | |
} |
335 | |
|
336 | |
public Service createService(InternationalString name) throws JAXRException { |
337 | 0 | Service ser = (Service) this.createObject(LifeCycleManager.SERVICE); |
338 | 0 | ser.setName(name); |
339 | 0 | 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 | 0 | 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 | 0 | return (SpecificationLink) this.createObject(LifeCycleManager.SPECIFICATION_LINK); |
370 | |
} |
371 | |
|
372 | |
public TelephoneNumber createTelephoneNumber() throws JAXRException { |
373 | 0 | return (TelephoneNumber) this.createObject(LifeCycleManager.TELEPHONE_NUMBER); |
374 | |
} |
375 | |
|
376 | |
public User createUser() throws JAXRException { |
377 | 0 | 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 | 0 | throw new UnsupportedCapabilityException(); |
427 | |
} |
428 | |
|
429 | |
public RegistryPackage createRegistryPackage(String name) throws JAXRException { |
430 | 0 | throw new UnsupportedCapabilityException(); |
431 | |
} |
432 | |
|
433 | |
public BulkResponse deprecateObjects(Collection keys) throws JAXRException { |
434 | 0 | throw new UnsupportedCapabilityException(); |
435 | |
} |
436 | |
|
437 | |
public BulkResponse unDeprecateObjects(Collection keys) throws JAXRException { |
438 | 0 | throw new UnsupportedCapabilityException(); |
439 | |
} |
440 | |
|
441 | |
public BulkResponse deleteObjects(Collection keys) throws JAXRException { |
442 | 0 | throw new UnsupportedCapabilityException(); |
443 | |
} |
444 | |
|
445 | |
} |