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.net.PasswordAuthentication; |
20 | |
import java.util.ArrayList; |
21 | |
import java.util.Collection; |
22 | |
import java.util.Iterator; |
23 | |
import java.util.LinkedHashSet; |
24 | |
import java.util.List; |
25 | |
import java.util.Set; |
26 | |
|
27 | |
import javax.xml.registry.BulkResponse; |
28 | |
import javax.xml.registry.BusinessLifeCycleManager; |
29 | |
import javax.xml.registry.BusinessQueryManager; |
30 | |
import javax.xml.registry.InvalidRequestException; |
31 | |
import javax.xml.registry.JAXRException; |
32 | |
import javax.xml.registry.LifeCycleManager; |
33 | |
import javax.xml.registry.RegistryService; |
34 | |
import javax.xml.registry.UnsupportedCapabilityException; |
35 | |
import javax.xml.registry.infomodel.Association; |
36 | |
import javax.xml.registry.infomodel.ClassificationScheme; |
37 | |
import javax.xml.registry.infomodel.Concept; |
38 | |
import javax.xml.registry.infomodel.Key; |
39 | |
import javax.xml.registry.infomodel.LocalizedString; |
40 | |
import javax.xml.registry.infomodel.Organization; |
41 | |
import javax.xml.registry.infomodel.RegistryObject; |
42 | |
import javax.xml.registry.infomodel.Service; |
43 | |
import javax.xml.registry.infomodel.ServiceBinding; |
44 | |
|
45 | |
import org.apache.commons.logging.Log; |
46 | |
import org.apache.commons.logging.LogFactory; |
47 | |
import org.apache.ws.scout.model.uddi.v2.AssertionStatusItem; |
48 | |
import org.apache.ws.scout.model.uddi.v2.AssertionStatusReport; |
49 | |
import org.apache.ws.scout.model.uddi.v2.AuthToken; |
50 | |
import org.apache.ws.scout.model.uddi.v2.BindingDetail; |
51 | |
import org.apache.ws.scout.model.uddi.v2.BindingTemplate; |
52 | |
import org.apache.ws.scout.model.uddi.v2.BusinessDetail; |
53 | |
import org.apache.ws.scout.model.uddi.v2.BusinessInfo; |
54 | |
import org.apache.ws.scout.model.uddi.v2.BusinessInfos; |
55 | |
import org.apache.ws.scout.model.uddi.v2.BusinessList; |
56 | |
import org.apache.ws.scout.model.uddi.v2.BusinessService; |
57 | |
import org.apache.ws.scout.model.uddi.v2.FindQualifiers; |
58 | |
import org.apache.ws.scout.model.uddi.v2.KeyedReference; |
59 | |
import org.apache.ws.scout.model.uddi.v2.Name; |
60 | |
import org.apache.ws.scout.model.uddi.v2.ObjectFactory; |
61 | |
import org.apache.ws.scout.model.uddi.v2.PublisherAssertion; |
62 | |
import org.apache.ws.scout.model.uddi.v2.PublisherAssertions; |
63 | |
import org.apache.ws.scout.model.uddi.v2.RegisteredInfo; |
64 | |
import org.apache.ws.scout.model.uddi.v2.ServiceDetail; |
65 | |
import org.apache.ws.scout.model.uddi.v2.ServiceInfo; |
66 | |
import org.apache.ws.scout.model.uddi.v2.ServiceInfos; |
67 | |
import org.apache.ws.scout.model.uddi.v2.ServiceList; |
68 | |
import org.apache.ws.scout.model.uddi.v2.TModel; |
69 | |
import org.apache.ws.scout.model.uddi.v2.TModelDetail; |
70 | |
import org.apache.ws.scout.model.uddi.v2.TModelInfo; |
71 | |
import org.apache.ws.scout.model.uddi.v2.TModelInfos; |
72 | |
import org.apache.ws.scout.model.uddi.v2.TModelList; |
73 | |
import org.apache.ws.scout.registry.infomodel.AssociationImpl; |
74 | |
import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl; |
75 | |
import org.apache.ws.scout.registry.infomodel.ConceptImpl; |
76 | |
import org.apache.ws.scout.registry.infomodel.InternationalStringImpl; |
77 | |
import org.apache.ws.scout.registry.infomodel.KeyImpl; |
78 | |
import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl; |
79 | |
import org.apache.ws.scout.registry.infomodel.ServiceImpl; |
80 | |
import org.apache.ws.scout.util.EnumerationHelper; |
81 | |
import org.apache.ws.scout.util.ScoutJaxrUddiHelper; |
82 | |
import org.apache.ws.scout.util.ScoutUddiJaxrHelper; |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
public class BusinessQueryManagerImpl implements BusinessQueryManager |
94 | |
{ |
95 | |
private final RegistryServiceImpl registryService; |
96 | 0 | private Log log = LogFactory.getLog(this.getClass()); |
97 | |
|
98 | 0 | private static ObjectFactory objectFactory = new ObjectFactory(); |
99 | |
|
100 | |
public BusinessQueryManagerImpl(RegistryServiceImpl registry) |
101 | 0 | { |
102 | 0 | this.registryService = registry; |
103 | 0 | } |
104 | |
|
105 | |
public RegistryService getRegistryService() |
106 | |
{ |
107 | 0 | return registryService; |
108 | |
} |
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public BulkResponse findOrganizations(Collection findQualifiers, |
123 | |
Collection namePatterns, |
124 | |
Collection classifications, |
125 | |
Collection specifications, |
126 | |
Collection externalIdentifiers, |
127 | |
Collection externalLinks) throws JAXRException |
128 | |
{ |
129 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
130 | |
try |
131 | |
{ |
132 | 0 | FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers); |
133 | 0 | Name[] nameArray = mapNamePatterns(namePatterns); |
134 | 0 | BusinessList result = registry.findBusiness(nameArray, |
135 | |
null, |
136 | |
ScoutJaxrUddiHelper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers), |
137 | |
ScoutJaxrUddiHelper.getCategoryBagFromClassifications(classifications), |
138 | |
null, |
139 | |
juddiFindQualifiers, |
140 | |
registryService.getMaxRows()); |
141 | |
|
142 | 0 | BusinessInfo[] bizInfoArr =null; |
143 | 0 | BusinessInfos bizInfos = result.getBusinessInfos(); |
144 | 0 | LinkedHashSet<Organization> orgs = new LinkedHashSet<Organization>(); |
145 | 0 | if(bizInfos != null) |
146 | |
{ |
147 | 0 | List<BusinessInfo> bizInfoList = bizInfos.getBusinessInfo(); |
148 | 0 | for (BusinessInfo businessInfo : bizInfoList) { |
149 | |
|
150 | 0 | BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey()); |
151 | 0 | orgs.add(((BusinessLifeCycleManagerImpl)registryService.getLifeCycleManagerImpl()).createOrganization(detail)); |
152 | 0 | } |
153 | 0 | bizInfoArr = new BusinessInfo[bizInfoList.size()]; |
154 | 0 | bizInfoList.toArray(bizInfoArr); |
155 | |
} |
156 | 0 | return new BulkResponseImpl(orgs); |
157 | 0 | } catch (RegistryException e) |
158 | |
{ |
159 | 0 | throw new JAXRException(e); |
160 | |
} |
161 | |
} |
162 | |
|
163 | |
public BulkResponse findAssociations(Collection findQualifiers, |
164 | |
String sourceObjectId, |
165 | |
String targetObjectId, |
166 | |
Collection associationTypes) throws JAXRException |
167 | |
{ |
168 | |
|
169 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
170 | |
try |
171 | |
{ |
172 | 0 | ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection(); |
173 | 0 | AuthToken auth = this.getAuthToken(con,registry); |
174 | 0 | PublisherAssertions result = null; |
175 | |
try { |
176 | 0 | result = registry.getPublisherAssertions(auth.getAuthInfo()); |
177 | 0 | } catch (RegistryException rve) { |
178 | 0 | String username = getUsernameFromCredentials(con.getCredentials()); |
179 | 0 | if (AuthTokenSingleton.getToken(username) != null) { |
180 | 0 | AuthTokenSingleton.deleteAuthToken(username); |
181 | |
} |
182 | 0 | auth = getAuthToken(con, registry); |
183 | 0 | result = registry.getPublisherAssertions(auth.getAuthInfo()); |
184 | 0 | } |
185 | |
|
186 | 0 | List<PublisherAssertion> publisherAssertionList = result.getPublisherAssertion(); |
187 | 0 | LinkedHashSet<Association> col = new LinkedHashSet<Association>(); |
188 | 0 | for (PublisherAssertion pas : publisherAssertionList) { |
189 | 0 | String sourceKey = pas.getFromKey(); |
190 | 0 | String targetKey = pas.getToKey(); |
191 | |
|
192 | 0 | if ((sourceObjectId==null || sourceObjectId.equals(sourceKey)) |
193 | |
&& (targetObjectId==null || targetObjectId.equals(targetKey))) { |
194 | 0 | Collection<Key> orgcol = new ArrayList<Key>(); |
195 | 0 | orgcol.add(new KeyImpl(sourceKey)); |
196 | 0 | orgcol.add(new KeyImpl(targetKey)); |
197 | 0 | BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION); |
198 | 0 | Association asso = ScoutUddiJaxrHelper.getAssociation(bl.getCollection(), |
199 | |
registryService.getBusinessLifeCycleManager()); |
200 | 0 | KeyedReference keyr = pas.getKeyedReference(); |
201 | 0 | Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager()); |
202 | 0 | c.setName(new InternationalStringImpl(keyr.getKeyName())); |
203 | 0 | c.setKey( new KeyImpl(keyr.getTModelKey()) ); |
204 | 0 | c.setValue(keyr.getKeyValue()); |
205 | 0 | asso.setAssociationType(c); |
206 | 0 | col.add(asso); |
207 | |
} |
208 | |
|
209 | 0 | } |
210 | 0 | return new BulkResponseImpl(col); |
211 | 0 | } catch (RegistryException e) |
212 | |
{ |
213 | 0 | throw new JAXRException(e); |
214 | |
} |
215 | |
} |
216 | |
|
217 | |
public BulkResponse findCallerAssociations(Collection findQualifiers, |
218 | |
Boolean confirmedByCaller, |
219 | |
Boolean confirmedByOtherParty, |
220 | |
Collection associationTypes) throws JAXRException |
221 | |
{ |
222 | |
|
223 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
224 | |
try |
225 | |
{ |
226 | 0 | ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection(); |
227 | 0 | AuthToken auth = this.getAuthToken(con,registry); |
228 | |
|
229 | 0 | AssertionStatusReport report = null; |
230 | 0 | String confirm = ""; |
231 | 0 | boolean caller = confirmedByCaller.booleanValue(); |
232 | 0 | boolean other = confirmedByOtherParty.booleanValue(); |
233 | |
|
234 | 0 | if(caller && other ) |
235 | 0 | confirm = Constants.COMPLETION_STATUS_COMPLETE; |
236 | |
else |
237 | 0 | if(!caller && other ) |
238 | 0 | confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE; |
239 | |
else |
240 | 0 | if(caller && !other ) |
241 | 0 | confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE; |
242 | |
|
243 | 0 | report = null; |
244 | |
try { |
245 | 0 | report = registry.getAssertionStatusReport(auth.getAuthInfo(),confirm); |
246 | 0 | } catch (RegistryException rve) { |
247 | 0 | String username = getUsernameFromCredentials(con.getCredentials()); |
248 | 0 | if (AuthTokenSingleton.getToken(username) != null) { |
249 | 0 | AuthTokenSingleton.deleteAuthToken(username); |
250 | |
} |
251 | 0 | auth = getAuthToken(con, registry); |
252 | 0 | report = registry.getAssertionStatusReport(auth.getAuthInfo(),confirm); |
253 | 0 | } |
254 | |
|
255 | 0 | List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem(); |
256 | 0 | LinkedHashSet<Association> col = new LinkedHashSet<Association>(); |
257 | 0 | for (AssertionStatusItem asi : assertionStatusItemList) { |
258 | 0 | String sourceKey = asi.getFromKey(); |
259 | 0 | String targetKey = asi.getToKey(); |
260 | 0 | Collection<Key> orgcol = new ArrayList<Key>(); |
261 | 0 | orgcol.add(new KeyImpl(sourceKey)); |
262 | 0 | orgcol.add(new KeyImpl(targetKey)); |
263 | 0 | BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION); |
264 | 0 | Association asso = ScoutUddiJaxrHelper.getAssociation(bl.getCollection(), |
265 | |
registryService.getBusinessLifeCycleManager()); |
266 | |
|
267 | 0 | ((AssociationImpl)asso).setConfirmedBySourceOwner(caller); |
268 | 0 | ((AssociationImpl)asso).setConfirmedByTargetOwner(other); |
269 | |
|
270 | 0 | if(confirm != Constants.COMPLETION_STATUS_COMPLETE) |
271 | 0 | ((AssociationImpl)asso).setConfirmed(false); |
272 | |
|
273 | 0 | Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager()); |
274 | 0 | KeyedReference keyr = asi.getKeyedReference(); |
275 | 0 | c.setKey(new KeyImpl(keyr.getTModelKey())); |
276 | 0 | c.setName(new InternationalStringImpl(keyr.getKeyName())); |
277 | 0 | c.setValue(keyr.getKeyValue()); |
278 | 0 | asso.setKey(new KeyImpl(keyr.getTModelKey())); |
279 | 0 | asso.setAssociationType(c); |
280 | 0 | col.add(asso); |
281 | 0 | } |
282 | |
|
283 | |
|
284 | 0 | return new BulkResponseImpl(col); |
285 | 0 | } catch (RegistryException e) |
286 | |
{ |
287 | 0 | throw new JAXRException(e); |
288 | |
} |
289 | |
} |
290 | |
|
291 | |
|
292 | |
|
293 | |
|
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
public ClassificationScheme findClassificationSchemeByName(Collection findQualifiers, |
300 | |
String namePatterns) throws JAXRException |
301 | |
{ |
302 | 0 | ClassificationScheme scheme = null; |
303 | |
|
304 | 0 | if (namePatterns.indexOf("uddi-org:types") != -1) { |
305 | |
|
306 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
307 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
308 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_TYPES_TMODEL_KEY)); |
309 | |
} |
310 | 0 | else if (namePatterns.indexOf("dnb-com:D-U-N-S") != -1) { |
311 | |
|
312 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
313 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
314 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_D_U_N_S_TMODEL_KEY)); |
315 | |
} |
316 | 0 | else if (namePatterns.indexOf("uddi-org:iso-ch:3166:1999") != -1) |
317 | |
{ |
318 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
319 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
320 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY)); |
321 | |
} |
322 | 0 | else if (namePatterns.indexOf("uddi-org:iso-ch:3166-1999") != -1) |
323 | |
{ |
324 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
325 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
326 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY)); |
327 | |
} |
328 | 0 | else if (namePatterns.indexOf("iso-ch:3166:1999") != -1) |
329 | |
{ |
330 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
331 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
332 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY)); |
333 | |
} |
334 | 0 | else if (namePatterns.indexOf("iso-ch:3166-1999") != -1) |
335 | |
{ |
336 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
337 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
338 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY)); |
339 | |
} |
340 | 0 | else if (namePatterns.indexOf("unspsc-org:unspsc") != -1) { |
341 | |
|
342 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
343 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
344 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY)); |
345 | |
} |
346 | 0 | else if (namePatterns.indexOf("ntis-gov:naics") != -1) { |
347 | |
|
348 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
349 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
350 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_NAICS_TMODEL_KEY)); |
351 | |
} |
352 | |
else |
353 | |
{ |
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | 0 | if ("AssociationType".equals(namePatterns)) { |
360 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
361 | |
|
362 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
363 | |
|
364 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY)); |
365 | |
|
366 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "RelatedTo"); |
367 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "HasChild"); |
368 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "HasMember"); |
369 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "HasParent"); |
370 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "ExternallyLinks"); |
371 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Contains"); |
372 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "EquivalentTo"); |
373 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Extends"); |
374 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Implements"); |
375 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "InstanceOf"); |
376 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Supersedes"); |
377 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Uses"); |
378 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Replaces"); |
379 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "ResponsibleFor"); |
380 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "SubmitterOf"); |
381 | |
} |
382 | 0 | else if ("ObjectType".equals(namePatterns)) { |
383 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
384 | |
|
385 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
386 | |
|
387 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY)); |
388 | |
|
389 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "CPP"); |
390 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "CPA"); |
391 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Process"); |
392 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "WSDL"); |
393 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Association"); |
394 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "AuditableEvent"); |
395 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Classification"); |
396 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Concept"); |
397 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "ExternalIdentifier"); |
398 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "ExternalLink"); |
399 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "ExtrinsicObject"); |
400 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Organization"); |
401 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Package"); |
402 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Service"); |
403 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "ServiceBinding"); |
404 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "User"); |
405 | |
} |
406 | 0 | else if ("PhoneType".equals(namePatterns)) { |
407 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
408 | |
|
409 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
410 | |
|
411 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY)); |
412 | |
|
413 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "OfficePhone"); |
414 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "HomePhone"); |
415 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "MobilePhone"); |
416 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Beeper"); |
417 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "FAX"); |
418 | |
} |
419 | 0 | else if ("URLType".equals(namePatterns)) { |
420 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
421 | |
|
422 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
423 | |
|
424 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY)); |
425 | |
|
426 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "HTTP"); |
427 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "HTTPS"); |
428 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "SMTP"); |
429 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "PHONE"); |
430 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "FAX"); |
431 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "OTHER"); |
432 | |
} |
433 | 0 | else if ("PostalAddressAttributes".equals(namePatterns)) { |
434 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
435 | |
|
436 | 0 | scheme.setName(new InternationalStringImpl(namePatterns)); |
437 | |
|
438 | 0 | scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY)); |
439 | |
|
440 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "StreetNumber"); |
441 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Street"); |
442 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "City"); |
443 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "State"); |
444 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "PostalCode"); |
445 | 0 | addChildConcept((ClassificationSchemeImpl)scheme, "Country"); |
446 | |
} |
447 | |
else { |
448 | |
|
449 | |
|
450 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
451 | 0 | FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers); |
452 | |
try |
453 | |
{ |
454 | |
|
455 | 0 | TModelList list = registry.findTModel(namePatterns, null, null, juddiFindQualifiers, 3); |
456 | 0 | if (list != null) { |
457 | 0 | TModelInfos infos = list.getTModelInfos(); |
458 | 0 | if (infos != null) { |
459 | 0 | List<TModelInfo> tmodelInfoList = infos.getTModelInfo(); |
460 | 0 | if (tmodelInfoList.size() > 1) { |
461 | 0 | throw new InvalidRequestException("Multiple matches found:" + tmodelInfoList.size()); |
462 | |
} |
463 | 0 | if (tmodelInfoList.size() ==1) { |
464 | 0 | TModelInfo info = tmodelInfoList.get(0); |
465 | 0 | scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl()); |
466 | 0 | scheme.setName(new InternationalStringImpl(info.getName().getValue())); |
467 | 0 | scheme.setKey(new KeyImpl(info.getTModelKey())); |
468 | |
} |
469 | |
} |
470 | |
} |
471 | |
|
472 | 0 | } catch (RegistryException e) |
473 | |
{ |
474 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
475 | 0 | } |
476 | |
} |
477 | |
} |
478 | 0 | return scheme; |
479 | |
} |
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
|
488 | |
private void addChildConcept(ClassificationSchemeImpl scheme, String name) |
489 | |
throws JAXRException { |
490 | 0 | Concept c = new ConceptImpl(registryService.getLifeCycleManagerImpl()); |
491 | |
|
492 | 0 | c.setName(new InternationalStringImpl(name)); |
493 | 0 | c.setValue(name); |
494 | 0 | ((ConceptImpl)c).setScheme((ClassificationSchemeImpl)scheme); |
495 | |
|
496 | 0 | scheme.addChildConcept(c); |
497 | 0 | } |
498 | |
|
499 | |
public BulkResponse findClassificationSchemes(Collection findQualifiers, |
500 | |
Collection namePatterns, |
501 | |
Collection classifications, |
502 | |
Collection externalLinks) throws JAXRException |
503 | |
{ |
504 | |
|
505 | 0 | LinkedHashSet<ClassificationScheme> col = new LinkedHashSet<ClassificationScheme>(); |
506 | 0 | Iterator iter = namePatterns.iterator(); |
507 | 0 | String name = ""; |
508 | 0 | while(iter.hasNext()) |
509 | |
{ |
510 | 0 | name = (String)iter.next(); |
511 | |
break; |
512 | |
} |
513 | |
|
514 | 0 | ClassificationScheme classificationScheme = findClassificationSchemeByName(findQualifiers,name); |
515 | 0 | if (classificationScheme!=null) { |
516 | 0 | col.add(classificationScheme); |
517 | |
} |
518 | 0 | return new BulkResponseImpl(col); |
519 | |
} |
520 | |
|
521 | |
public Concept findConceptByPath(String path) throws JAXRException |
522 | |
{ |
523 | |
|
524 | |
|
525 | |
|
526 | |
|
527 | |
|
528 | 0 | return EnumerationHelper.getConceptByPath(path); |
529 | |
} |
530 | |
|
531 | |
public BulkResponse findConcepts(Collection findQualifiers, |
532 | |
Collection namePatterns, |
533 | |
Collection classifications, |
534 | |
Collection externalIdentifiers, |
535 | |
Collection externalLinks) throws JAXRException |
536 | |
{ |
537 | 0 | LinkedHashSet<Concept> col = new LinkedHashSet<Concept>(); |
538 | |
|
539 | |
|
540 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
541 | 0 | FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers); |
542 | 0 | Iterator iter = null; |
543 | 0 | if (namePatterns != null) iter = namePatterns.iterator(); |
544 | 0 | while (iter.hasNext()) |
545 | |
{ |
546 | 0 | String namestr = (String) iter.next(); |
547 | |
try |
548 | |
{ |
549 | 0 | TModelList list = registry.findTModel(namestr, |
550 | |
ScoutJaxrUddiHelper.getCategoryBagFromClassifications(classifications), |
551 | |
ScoutJaxrUddiHelper.getIdentifierBagFromExternalIdentifiers(externalIdentifiers), |
552 | |
juddiFindQualifiers, 10); |
553 | |
|
554 | 0 | if (list != null && list.getTModelInfos()!=null) { |
555 | 0 | List<TModelInfo> tmodelInfoList = list.getTModelInfos().getTModelInfo(); |
556 | 0 | if (tmodelInfoList!=null) { |
557 | 0 | for (TModelInfo info: tmodelInfoList) { |
558 | 0 | col.add(ScoutUddiJaxrHelper.getConcept(info, this.registryService.getBusinessLifeCycleManager())); |
559 | |
} |
560 | |
} |
561 | |
} |
562 | 0 | } catch (RegistryException e) { |
563 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
564 | 0 | } |
565 | 0 | } |
566 | |
|
567 | 0 | return new BulkResponseImpl(col); |
568 | |
} |
569 | |
|
570 | |
public BulkResponse findRegistryPackages(Collection findQualifiers, |
571 | |
Collection namePatterns, |
572 | |
Collection classifications, |
573 | |
Collection externalLinks) throws JAXRException |
574 | |
{ |
575 | 0 | throw new UnsupportedCapabilityException(); |
576 | |
} |
577 | |
|
578 | |
public BulkResponse findServiceBindings(Key serviceKey, |
579 | |
Collection findQualifiers, |
580 | |
Collection classifications, |
581 | |
Collection specifications) throws JAXRException |
582 | |
{ |
583 | 0 | BulkResponseImpl blkRes = new BulkResponseImpl(); |
584 | |
|
585 | 0 | IRegistry iRegistry = (IRegistry) registryService.getRegistry(); |
586 | 0 | FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers); |
587 | |
|
588 | |
try |
589 | |
{ |
590 | |
|
591 | 0 | BindingDetail bindingDetail = iRegistry.findBinding(serviceKey.getId(), |
592 | |
ScoutJaxrUddiHelper.getCategoryBagFromClassifications(classifications), |
593 | |
ScoutJaxrUddiHelper.getTModelBagFromSpecifications(specifications), |
594 | |
juddiFindQualifiers,registryService.getMaxRows()); |
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | 0 | if (bindingDetail != null) { |
600 | |
|
601 | 0 | List<BindingTemplate> bindingTemplateList = bindingDetail.getBindingTemplate(); |
602 | 0 | BindingTemplate[] bindarr = new BindingTemplate[bindingTemplateList.size()]; |
603 | 0 | bindingTemplateList.toArray(bindarr); |
604 | |
|
605 | 0 | LinkedHashSet<ServiceBinding> col = new LinkedHashSet<ServiceBinding>(); |
606 | |
|
607 | 0 | for (int i=0; bindarr != null && i < bindarr.length; i++) { |
608 | 0 | BindingTemplate si = bindarr[i]; |
609 | 0 | ServiceBinding sb = ScoutUddiJaxrHelper.getServiceBinding(si, |
610 | |
registryService.getBusinessLifeCycleManager()); |
611 | 0 | col.add(sb); |
612 | |
|
613 | 0 | Service s = (Service)getRegistryObject(serviceKey.getId(), LifeCycleManager.SERVICE); |
614 | 0 | ((ServiceBindingImpl)sb).setService(s); |
615 | |
} |
616 | |
|
617 | 0 | blkRes.setCollection(col); |
618 | |
} |
619 | |
} |
620 | 0 | catch (RegistryException e) { |
621 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
622 | 0 | } |
623 | |
|
624 | 0 | return blkRes; |
625 | |
} |
626 | |
|
627 | |
|
628 | |
|
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
|
637 | |
|
638 | |
|
639 | |
|
640 | |
|
641 | |
|
642 | |
|
643 | |
public BulkResponse findServices(Key orgKey, Collection findQualifiers, |
644 | |
Collection namePatterns, |
645 | |
Collection classifications, |
646 | |
Collection specificationa) throws JAXRException |
647 | |
{ |
648 | 0 | BulkResponseImpl blkRes = new BulkResponseImpl(); |
649 | |
|
650 | 0 | IRegistry iRegistry = (IRegistry) registryService.getRegistry(); |
651 | 0 | FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers); |
652 | 0 | Name[] juddiNames = mapNamePatterns(namePatterns); |
653 | |
|
654 | |
try |
655 | |
{ |
656 | |
|
657 | |
|
658 | |
|
659 | |
|
660 | 0 | String id = null; |
661 | |
|
662 | 0 | if (orgKey != null) { |
663 | 0 | id = orgKey.getId(); |
664 | |
} |
665 | |
|
666 | 0 | ServiceList serviceList = iRegistry.findService(id, |
667 | |
juddiNames, |
668 | |
ScoutJaxrUddiHelper.getCategoryBagFromClassifications(classifications), |
669 | |
null, |
670 | |
juddiFindQualifiers, registryService.getMaxRows()); |
671 | |
|
672 | |
|
673 | |
|
674 | |
|
675 | 0 | if (serviceList != null) { |
676 | |
|
677 | 0 | ServiceInfos serviceInfos = serviceList.getServiceInfos(); |
678 | 0 | LinkedHashSet<Service> col = new LinkedHashSet<Service>(); |
679 | |
|
680 | 0 | if(serviceInfos != null && serviceInfos.getServiceInfo()!=null) { |
681 | 0 | for (ServiceInfo si : serviceInfos.getServiceInfo()) { |
682 | 0 | Service srv = (Service) getRegistryObject(si.getServiceKey(), LifeCycleManager.SERVICE); |
683 | 0 | col.add(srv); |
684 | 0 | } |
685 | |
|
686 | |
} |
687 | 0 | blkRes.setCollection(col); |
688 | |
} |
689 | |
} |
690 | 0 | catch (RegistryException e) { |
691 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
692 | 0 | } |
693 | |
|
694 | 0 | return blkRes; |
695 | |
} |
696 | |
|
697 | |
public RegistryObject getRegistryObject(String id) throws JAXRException |
698 | |
{ |
699 | 0 | throw new UnsupportedCapabilityException(); |
700 | |
} |
701 | |
|
702 | |
public RegistryObject getRegistryObject(String id, String objectType) throws JAXRException |
703 | |
{ |
704 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
705 | 0 | BusinessLifeCycleManager lcm = registryService.getBusinessLifeCycleManager(); |
706 | |
|
707 | 0 | if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) { |
708 | |
|
709 | |
try { |
710 | |
|
711 | 0 | TModelDetail tmodeldetail = registry.getTModelDetail(id); |
712 | 0 | Concept c = ScoutUddiJaxrHelper.getConcept(tmodeldetail, lcm); |
713 | |
|
714 | |
|
715 | |
|
716 | |
|
717 | |
|
718 | 0 | ClassificationScheme scheme = new ClassificationSchemeImpl(lcm); |
719 | |
|
720 | 0 | scheme.setName(c.getName()); |
721 | 0 | scheme.setDescription(c.getDescription()); |
722 | 0 | scheme.setKey(c.getKey()); |
723 | |
|
724 | 0 | return scheme; |
725 | |
} |
726 | 0 | catch (RegistryException e) { |
727 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
728 | |
} |
729 | |
} |
730 | 0 | else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) { |
731 | |
try |
732 | |
{ |
733 | 0 | BusinessDetail orgdetail = registry.getBusinessDetail(id); |
734 | 0 | return ScoutUddiJaxrHelper.getOrganization(orgdetail, lcm); |
735 | |
} |
736 | 0 | catch (RegistryException e) { |
737 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
738 | |
} |
739 | |
|
740 | |
} |
741 | 0 | else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) { |
742 | |
|
743 | |
try |
744 | |
{ |
745 | 0 | TModelDetail tmodeldetail = registry.getTModelDetail(id); |
746 | 0 | return ScoutUddiJaxrHelper.getConcept(tmodeldetail, lcm); |
747 | |
} |
748 | 0 | catch (RegistryException e) { |
749 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
750 | |
} |
751 | |
} |
752 | 0 | else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) { |
753 | |
|
754 | |
try { |
755 | 0 | ServiceDetail sd = registry.getServiceDetail(id); |
756 | 0 | if (sd != null && sd.getBusinessService()!=null) { |
757 | 0 | for (BusinessService businessService : sd.getBusinessService()) { |
758 | 0 | Service service = getServiceFromBusinessService(businessService, lcm); |
759 | 0 | return service; |
760 | |
} |
761 | |
} |
762 | |
} |
763 | 0 | catch (RegistryException e) { |
764 | 0 | throw new RuntimeException(e); |
765 | 0 | } |
766 | |
} |
767 | |
|
768 | 0 | return null; |
769 | |
} |
770 | |
|
771 | |
|
772 | |
|
773 | |
|
774 | |
|
775 | |
|
776 | |
|
777 | |
|
778 | |
|
779 | |
|
780 | |
|
781 | |
protected Service getServiceFromBusinessService(BusinessService bs, LifeCycleManager lcm) |
782 | |
throws JAXRException { |
783 | |
|
784 | 0 | ServiceImpl service = (ServiceImpl) ScoutUddiJaxrHelper.getService(bs, lcm); |
785 | 0 | service.setSubmittingOrganizationKey(bs.getBusinessKey()); |
786 | |
|
787 | 0 | return service; |
788 | |
} |
789 | |
|
790 | |
|
791 | |
|
792 | |
|
793 | |
|
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
|
800 | |
public BulkResponse getRegistryObjects() throws JAXRException |
801 | |
{ |
802 | 0 | String types[] = { |
803 | |
LifeCycleManager.ORGANIZATION, |
804 | |
LifeCycleManager.SERVICE}; |
805 | |
|
806 | 0 | LinkedHashSet<Object> c = new LinkedHashSet<Object>(); |
807 | |
|
808 | 0 | for (int i = 0; i < types.length; i++) { |
809 | |
try { |
810 | 0 | BulkResponse bk = getRegistryObjects(types[i]); |
811 | |
|
812 | 0 | if (bk.getCollection() != null) { |
813 | 0 | c.addAll(bk.getCollection()); |
814 | |
} |
815 | 0 | } catch(JAXRException e) { |
816 | 0 | log.debug("ignore - just a problem with that type? " + e.getMessage(), e); |
817 | 0 | } |
818 | |
} |
819 | |
|
820 | 0 | return new BulkResponseImpl(c); |
821 | |
} |
822 | |
|
823 | |
public BulkResponse getRegistryObjects(Collection objectKeys) throws JAXRException |
824 | |
{ |
825 | 0 | throw new UnsupportedCapabilityException(); |
826 | |
} |
827 | |
|
828 | |
public BulkResponse getRegistryObjects(Collection objectKeys, String objectType) throws JAXRException |
829 | |
{ |
830 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
831 | |
|
832 | 0 | String[] keys = new String[objectKeys.size()]; |
833 | 0 | int currLoc = 0; |
834 | 0 | for (Key key : (Collection<Key>) objectKeys) { |
835 | 0 | keys[currLoc] = key.getId(); |
836 | 0 | currLoc++; |
837 | |
} |
838 | 0 | LinkedHashSet<RegistryObject> col = new LinkedHashSet<RegistryObject>(); |
839 | 0 | LifeCycleManager lcm = registryService.getLifeCycleManagerImpl(); |
840 | |
|
841 | 0 | if (LifeCycleManager.CLASSIFICATION_SCHEME.equalsIgnoreCase(objectType)) |
842 | |
{ |
843 | |
try |
844 | |
{ |
845 | 0 | TModelDetail tmodeldetail = registry.getTModelDetail(keys); |
846 | 0 | List<TModel> tmodelList = tmodeldetail.getTModel(); |
847 | |
|
848 | 0 | for (TModel tModel: tmodelList) |
849 | |
{ |
850 | 0 | col.add(ScoutUddiJaxrHelper.getConcept(tModel, lcm)); |
851 | |
} |
852 | |
|
853 | 0 | } catch (RegistryException e) |
854 | |
{ |
855 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
856 | 0 | } |
857 | |
} |
858 | 0 | else if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(objectType)) |
859 | |
{ |
860 | 0 | ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection(); |
861 | 0 | AuthToken auth = this.getAuthToken(con,registry); |
862 | |
|
863 | |
try |
864 | |
{ |
865 | 0 | RegisteredInfo ri = null; |
866 | |
try { |
867 | 0 | ri = registry.getRegisteredInfo(auth.getAuthInfo()); |
868 | 0 | } catch (RegistryException rve) { |
869 | 0 | String username = getUsernameFromCredentials(con.getCredentials()); |
870 | 0 | if (AuthTokenSingleton.getToken(username) != null) { |
871 | 0 | AuthTokenSingleton.deleteAuthToken(username); |
872 | |
} |
873 | 0 | auth = getAuthToken(con, registry); |
874 | 0 | ri = registry.getRegisteredInfo(auth.getAuthInfo()); |
875 | 0 | } |
876 | |
|
877 | 0 | if (ri != null) { |
878 | 0 | for (String key:keys) { |
879 | 0 | BusinessDetail detail = registry.getBusinessDetail(key); |
880 | 0 | col.add(((BusinessLifeCycleManagerImpl)registryService.getLifeCycleManagerImpl()).createOrganization(detail)); |
881 | |
} |
882 | |
|
883 | |
} |
884 | 0 | } catch (RegistryException e) { |
885 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
886 | 0 | } |
887 | 0 | } |
888 | 0 | else if (LifeCycleManager.CONCEPT.equalsIgnoreCase(objectType)) |
889 | |
{ |
890 | |
try { |
891 | 0 | TModelDetail tmodeldetail = registry.getTModelDetail(keys); |
892 | 0 | List<TModel> tmodelList = tmodeldetail.getTModel(); |
893 | |
|
894 | 0 | for (TModel tmodel: tmodelList) |
895 | |
{ |
896 | 0 | col.add(ScoutUddiJaxrHelper.getConcept(tmodel, lcm)); |
897 | |
} |
898 | |
|
899 | |
} |
900 | 0 | catch (RegistryException e) |
901 | |
{ |
902 | 0 | throw new JAXRException(e.getLocalizedMessage()); |
903 | 0 | } |
904 | |
} |
905 | 0 | else if (LifeCycleManager.SERVICE.equalsIgnoreCase(objectType)) { |
906 | |
|
907 | |
try { |
908 | 0 | ServiceDetail serviceDetail = registry.getServiceDetail(keys); |
909 | |
|
910 | 0 | if (serviceDetail != null) { |
911 | 0 | List<BusinessService> bizServiceList = serviceDetail.getBusinessService(); |
912 | |
|
913 | 0 | for (BusinessService businessService: bizServiceList) { |
914 | |
|
915 | 0 | Service service = getServiceFromBusinessService(businessService, lcm); |
916 | |
|
917 | 0 | col.add(service); |
918 | 0 | } |
919 | |
} |
920 | |
} |
921 | 0 | catch (RegistryException e) { |
922 | 0 | throw new JAXRException(e); |
923 | 0 | } |
924 | |
} |
925 | |
else { |
926 | 0 | throw new JAXRException("Unsupported type " + objectType + |
927 | |
" for getRegistryObjects() in Apache Scout"); |
928 | |
} |
929 | |
|
930 | 0 | return new BulkResponseImpl(col); |
931 | |
|
932 | |
} |
933 | |
|
934 | |
public BulkResponse getRegistryObjects(String id) throws JAXRException |
935 | |
{ |
936 | 0 | if (LifeCycleManager.ORGANIZATION.equalsIgnoreCase(id)) { |
937 | 0 | IRegistry registry = (IRegistry) registryService.getRegistry(); |
938 | 0 | ConnectionImpl con = ((RegistryServiceImpl)getRegistryService()).getConnection(); |
939 | 0 | AuthToken auth = this.getAuthToken(con,registry); |
940 | 0 | LinkedHashSet<Organization> orgs = null; |
941 | |
try |
942 | |
{ |
943 | 0 | RegisteredInfo ri = null; |
944 | |
try { |
945 | 0 | ri = registry.getRegisteredInfo(auth.getAuthInfo()); |
946 | 0 | } catch (RegistryException rve) { |
947 | 0 | String username = getUsernameFromCredentials(con.getCredentials()); |
948 | 0 | if (AuthTokenSingleton.getToken(username) != null) { |
949 | 0 | AuthTokenSingleton.deleteAuthToken(username); |
950 | |
} |
951 | 0 | auth = getAuthToken(con, registry); |
952 | 0 | ri = registry.getRegisteredInfo(auth.getAuthInfo()); |
953 | 0 | } |
954 | |
|
955 | 0 | if (ri != null && ri.getBusinessInfos()!=null) { |
956 | 0 | List<BusinessInfo> bizInfoList = ri.getBusinessInfos().getBusinessInfo(); |
957 | 0 | orgs = new LinkedHashSet<Organization>(); |
958 | 0 | for (BusinessInfo businessInfo : bizInfoList) { |
959 | 0 | BusinessDetail detail = registry.getBusinessDetail(businessInfo.getBusinessKey()); |
960 | 0 | orgs.add(((BusinessLifeCycleManagerImpl)registryService.getLifeCycleManagerImpl()).createOrganization(detail)); |
961 | 0 | } |
962 | |
} |
963 | |
|
964 | 0 | } catch (RegistryException re) { |
965 | 0 | throw new JAXRException(re); |
966 | 0 | } |
967 | 0 | return new BulkResponseImpl(orgs); |
968 | |
} |
969 | 0 | else if (LifeCycleManager.SERVICE.equalsIgnoreCase(id)) { |
970 | 0 | List<String> a = new ArrayList<String>(); |
971 | 0 | a.add("%"); |
972 | |
|
973 | 0 | BulkResponse br = this.findServices(null,null, a, null, null); |
974 | |
|
975 | 0 | return br; |
976 | |
} |
977 | |
else |
978 | |
{ |
979 | 0 | throw new JAXRException("Unsupported type for getRegistryObjects() :" + id); |
980 | |
} |
981 | |
|
982 | |
} |
983 | |
|
984 | |
static FindQualifiers mapFindQualifiers(Collection jaxrQualifiers) throws UnsupportedCapabilityException |
985 | |
{ |
986 | 0 | if (jaxrQualifiers == null) |
987 | |
{ |
988 | 0 | return null; |
989 | |
} |
990 | 0 | FindQualifiers result = objectFactory.createFindQualifiers(); |
991 | 0 | for (Iterator i = jaxrQualifiers.iterator(); i.hasNext();) |
992 | |
{ |
993 | 0 | String jaxrQualifier = (String) i.next(); |
994 | 0 | String juddiQualifier = jaxrQualifier; |
995 | 0 | if (juddiQualifier == null) |
996 | |
{ |
997 | 0 | throw new UnsupportedCapabilityException("jUDDI does not support FindQualifer: " + jaxrQualifier); |
998 | |
} |
999 | 0 | result.getFindQualifier().add(juddiQualifier); |
1000 | 0 | } |
1001 | 0 | return result; |
1002 | |
} |
1003 | |
|
1004 | |
static Name[] mapNamePatterns(Collection namePatterns) |
1005 | |
throws JAXRException |
1006 | |
{ |
1007 | 0 | if (namePatterns == null) |
1008 | 0 | return null; |
1009 | 0 | Name[] result = new Name[namePatterns.size()]; |
1010 | 0 | int currLoc = 0; |
1011 | 0 | for (Iterator i = namePatterns.iterator(); i.hasNext();) |
1012 | |
{ |
1013 | 0 | Object obj = i.next(); |
1014 | 0 | Name name = objectFactory.createName(); |
1015 | 0 | if (obj instanceof String) { |
1016 | 0 | name.setValue((String)obj); |
1017 | 0 | } else if (obj instanceof LocalizedString) { |
1018 | 0 | LocalizedString ls = (LocalizedString)obj; |
1019 | 0 | name.setValue(ls.getValue()); |
1020 | 0 | name.setLang(ls.getLocale().getLanguage()); |
1021 | |
} |
1022 | 0 | result[currLoc] = name; |
1023 | 0 | currLoc++; |
1024 | 0 | } |
1025 | 0 | return result; |
1026 | |
} |
1027 | |
|
1028 | |
|
1029 | |
|
1030 | |
|
1031 | |
|
1032 | |
|
1033 | |
|
1034 | |
|
1035 | |
|
1036 | |
private AuthToken getAuthToken(ConnectionImpl connection, IRegistry ireg) |
1037 | |
throws JAXRException { |
1038 | 0 | Set creds = connection.getCredentials(); |
1039 | 0 | Iterator it = creds.iterator(); |
1040 | 0 | String username = "", pwd = ""; |
1041 | 0 | while (it.hasNext()) { |
1042 | 0 | PasswordAuthentication pass = (PasswordAuthentication) it.next(); |
1043 | 0 | username = pass.getUserName(); |
1044 | 0 | pwd = new String(pass.getPassword()); |
1045 | 0 | } |
1046 | |
|
1047 | 0 | if (AuthTokenSingleton.getToken(username) != null) { |
1048 | 0 | return (AuthToken) AuthTokenSingleton.getToken(username); |
1049 | |
} |
1050 | |
|
1051 | 0 | AuthToken token = null; |
1052 | |
try { |
1053 | 0 | token = ireg.getAuthToken(username, pwd); |
1054 | |
} |
1055 | 0 | catch (Exception e) { |
1056 | 0 | throw new JAXRException(e); |
1057 | 0 | } |
1058 | 0 | AuthTokenSingleton.addAuthToken(username, token); |
1059 | |
|
1060 | 0 | return token; |
1061 | |
} |
1062 | |
|
1063 | |
private String getUsernameFromCredentials(Set credentials) { |
1064 | 0 | String username = "", pwd = ""; |
1065 | |
|
1066 | 0 | if (credentials != null) { |
1067 | 0 | Iterator it = credentials.iterator(); |
1068 | 0 | while (it.hasNext()) { |
1069 | 0 | PasswordAuthentication pass = (PasswordAuthentication) it.next(); |
1070 | 0 | username = pass.getUserName(); |
1071 | 0 | } |
1072 | |
} |
1073 | 0 | return username; |
1074 | |
} |
1075 | |
|
1076 | |
} |