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