View Javadoc
1   /*
2    * Copyright 2014 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.v3.client.mapping;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.HashSet;
21  import java.util.List;
22  import java.util.Set;
23  import javax.xml.soap.SOAPFault;
24  import javax.xml.ws.soap.SOAPFaultException;
25  import org.apache.commons.logging.Log;
26  import org.apache.commons.logging.LogFactory;
27  import org.apache.juddi.api_v3.AccessPointType;
28  import org.apache.juddi.v3.client.UDDIConstants;
29  import org.apache.juddi.v3.client.UDDIv2Constants;
30  import org.uddi.api_v2.AssertionStatusReport;
31  import org.uddi.api_v2.GetBusinessDetailExt;
32  import org.uddi.api_v2.GetTModelDetail;
33  import org.uddi.api_v2.SetPublisherAssertions;
34  import org.uddi.api_v2.Truncated;
35  import org.uddi.api_v3.AccessPoint;
36  import org.uddi.api_v3.AddPublisherAssertions;
37  import org.uddi.api_v3.Address;
38  import org.uddi.api_v3.AssertionStatusItem;
39  import org.uddi.api_v3.BindingTemplate;
40  import org.uddi.api_v3.BindingTemplates;
41  import org.uddi.api_v3.BusinessDetail;
42  import org.uddi.api_v3.BusinessEntity;
43  import org.uddi.api_v3.BusinessInfo;
44  import org.uddi.api_v3.BusinessInfos;
45  import org.uddi.api_v3.BusinessList;
46  import org.uddi.api_v3.BusinessService;
47  import org.uddi.api_v3.BusinessServices;
48  import org.uddi.api_v3.CategoryBag;
49  import org.uddi.api_v3.CompletionStatus;
50  import org.uddi.api_v3.Contact;
51  import org.uddi.api_v3.Contacts;
52  import org.uddi.api_v3.DeleteBinding;
53  import org.uddi.api_v3.DeleteBusiness;
54  import org.uddi.api_v3.DeletePublisherAssertions;
55  import org.uddi.api_v3.DeleteService;
56  import org.uddi.api_v3.DeleteTModel;
57  import org.uddi.api_v3.Description;
58  import org.uddi.api_v3.Direction;
59  import org.uddi.api_v3.DiscoveryURL;
60  import org.uddi.api_v3.DiscoveryURLs;
61  import org.uddi.api_v3.Email;
62  import org.uddi.api_v3.ErrInfo;
63  import org.uddi.api_v3.FindBinding;
64  import org.uddi.api_v3.FindBusiness;
65  import org.uddi.api_v3.FindQualifiers;
66  import org.uddi.api_v3.FindRelatedBusinesses;
67  import org.uddi.api_v3.FindService;
68  import org.uddi.api_v3.FindTModel;
69  import org.uddi.api_v3.GetBindingDetail;
70  import org.uddi.api_v3.GetBusinessDetail;
71  import org.uddi.api_v3.GetRegisteredInfo;
72  import org.uddi.api_v3.GetServiceDetail;
73  import org.uddi.api_v3.HostingRedirector;
74  import org.uddi.api_v3.IdentifierBag;
75  import org.uddi.api_v3.InfoSelection;
76  import org.uddi.api_v3.InstanceDetails;
77  import org.uddi.api_v3.KeyType;
78  import org.uddi.api_v3.KeyedReference;
79  import org.uddi.api_v3.KeysOwned;
80  import org.uddi.api_v3.ListDescription;
81  import org.uddi.api_v3.Name;
82  import org.uddi.api_v3.OverviewDoc;
83  import org.uddi.api_v3.OverviewURL;
84  import org.uddi.api_v3.PersonName;
85  import org.uddi.api_v3.Phone;
86  import org.uddi.api_v3.PublisherAssertion;
87  import org.uddi.api_v3.RegisteredInfo;
88  import org.uddi.api_v3.RelatedBusinessInfo;
89  import org.uddi.api_v3.RelatedBusinessInfos;
90  import org.uddi.api_v3.RelatedBusinessesList;
91  import org.uddi.api_v3.Result;
92  import org.uddi.api_v3.SaveBinding;
93  import org.uddi.api_v3.SaveBusiness;
94  import org.uddi.api_v3.SaveService;
95  import org.uddi.api_v3.SaveTModel;
96  import org.uddi.api_v3.ServiceDetail;
97  import org.uddi.api_v3.ServiceInfo;
98  import org.uddi.api_v3.ServiceInfos;
99  import org.uddi.api_v3.ServiceList;
100 import org.uddi.api_v3.SharedRelationships;
101 import org.uddi.api_v3.TModel;
102 import org.uddi.api_v3.TModelBag;
103 import org.uddi.api_v3.TModelDetail;
104 import org.uddi.api_v3.TModelInfo;
105 import org.uddi.api_v3.TModelInfos;
106 import org.uddi.api_v3.TModelInstanceDetails;
107 import org.uddi.api_v3.TModelInstanceInfo;
108 import org.uddi.api_v3.TModelList;
109 import org.uddi.v2_service.DispositionReport;
110 import org.uddi.v3_service.DispositionReportFaultMessage;
111 
112 /**
113  * Converts UDDIv2 objects to UDDI v3 objects. Note: these functions do not take
114  * into account the differences in key naming conventions. The good news is that
115  * UDDIv3 has backwards compatibility with v2.
116  *
117  * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
118  */
119 public class MapUDDIv2Tov3 {
120 
121         public static org.uddi.api_v3.BusinessEntity MapBusiness(org.uddi.api_v2.BusinessEntity be) {
122                 if (be == null) {
123                         return null;
124                 }
125                 BusinessEntity item = new org.uddi.api_v3.BusinessEntity();
126                 item.setBusinessKey(be.getBusinessKey());
127                 item.getName().addAll(MapName(be.getName()));
128                 item.setCategoryBag(MapCategoryBag(be.getCategoryBag()));
129                 item.setDiscoveryURLs(MapDiscoveryURLs(be.getDiscoveryURLs()));
130                 item.getDescription().addAll(MapDescription(be.getDescription()));
131                 item.setContacts(MapContacts(be.getContacts()));
132                 item.setIdentifierBag(MapIdentBag(be.getIdentifierBag()));
133                 if (be.getBusinessServices() != null && !be.getBusinessServices().getBusinessService().isEmpty()) {
134                         item.setBusinessServices(new BusinessServices());
135                         item.getBusinessServices().getBusinessService().addAll(MapService(be.getBusinessServices().getBusinessService()));
136                 }
137                 return item;
138         }
139 
140         public static org.uddi.api_v3.BusinessService MapService(org.uddi.api_v2.BusinessService be) {
141                 if (be == null) {
142                         return null;
143                 }
144                 BusinessService item = new org.uddi.api_v3.BusinessService();
145                 item.setBusinessKey(be.getBusinessKey());
146                 item.setServiceKey(be.getServiceKey());
147                 item.getName().addAll(MapName(be.getName()));
148                 if (be.getBindingTemplates() != null && !be.getBindingTemplates().getBindingTemplate().isEmpty()) {
149                         item.setBindingTemplates(new BindingTemplates());
150                         item.getBindingTemplates().getBindingTemplate().addAll(MapBinding(be.getBindingTemplates().getBindingTemplate()));
151                 }
152                 item.setCategoryBag(MapCategoryBag(be.getCategoryBag()));
153                 item.getDescription().addAll(MapDescription(be.getDescription()));
154                 return item;
155         }
156 
157         public static List<org.uddi.api_v3.BusinessService> MapService(List<org.uddi.api_v2.BusinessService> be) {
158                 if (be == null) {
159                         return null;
160                 }
161                 List<org.uddi.api_v3.BusinessService> item = new ArrayList<BusinessService>();
162                 for (int i = 0; i < be.size(); i++) {
163                         item.add(MapService(be.get(i)));
164                 }
165                 return item;
166         }
167 
168         public static org.uddi.api_v3.BindingTemplate MapBinding(org.uddi.api_v2.BindingTemplate be) {
169                 if (be == null) {
170                         return null;
171                 }
172                 BindingTemplate item = new org.uddi.api_v3.BindingTemplate();
173                 item.setBindingKey(be.getBindingKey());
174                 item.setServiceKey(be.getServiceKey());
175 
176                 item.setAccessPoint(mapAccessPoint(be.getAccessPoint()));
177                 item.setHostingRedirector(mapHostingRedir(be.getHostingRedirector()));
178                 item.getDescription().addAll(MapDescription(be.getDescription()));
179                 item.setTModelInstanceDetails(MapTModelInstanceDetails(be.getTModelInstanceDetails()));
180 
181                 return item;
182         }
183 
184         public static List<org.uddi.api_v3.BindingTemplate> MapBinding(List<org.uddi.api_v2.BindingTemplate> be) {
185                 if (be == null) {
186                         return null;
187                 }
188                 List<org.uddi.api_v3.BindingTemplate> item = new ArrayList<BindingTemplate>();
189                 for (int i = 0; i < be.size(); i++) {
190                         item.add(MapBinding(be.get(i)));
191                 }
192                 return item;
193         }
194 
195         public static org.uddi.api_v3.TModel MapTModel(org.uddi.api_v2.TModel be) {
196                 if (be == null) {
197                         return null;
198                 }
199                 TModel item = new org.uddi.api_v3.TModel();
200                 item.setTModelKey(be.getTModelKey());
201                 item.setName(new Name(be.getName().getValue(), be.getName().getLang()));
202                 item.setCategoryBag(MapCategoryBag(be.getCategoryBag()));
203                 item.setIdentifierBag(MapIdentBag(be.getIdentifierBag()));
204                 item.getDescription().addAll(MapDescription(be.getDescription()));
205                 OverviewDoc MapOverviewDoc = mapOverviewDoc(be.getOverviewDoc());
206                 if (MapOverviewDoc != null) {
207                         item.getOverviewDoc().add(MapOverviewDoc);
208                 }
209                 return item;
210         }
211 
212         private static List<Name> MapName(List<org.uddi.api_v2.Name> name) {
213                 List<Name> items = new ArrayList<Name>();
214                 for (int i = 0; i < name.size(); i++) {
215                         Name n = new Name(name.get(i).getValue(), name.get(i).getLang());
216                         items.add(n);
217                 }
218                 return items;
219         }
220 
221         private static CategoryBag MapCategoryBag(org.uddi.api_v2.CategoryBag categoryBag) {
222                 if (categoryBag == null) {
223                         return null;
224                 }
225                 CategoryBag c = new CategoryBag();
226                 c.getKeyedReference().addAll(MapKeyedReference(categoryBag.getKeyedReference()));
227                 return c;
228         }
229 
230         private static List<Description> MapDescription(List<org.uddi.api_v2.Description> description) {
231                 List<Description> ret = new ArrayList<Description>();
232                 if (description == null || description.isEmpty()) {
233                         return ret;
234                 }
235                 for (int i = 0; i < description.size(); i++) {
236                         ret.add(new Description(description.get(i).getValue(), description.get(i).getLang()));
237                 }
238                 return ret;
239 
240         }
241 
242         private static IdentifierBag MapIdentBag(org.uddi.api_v2.IdentifierBag identifierBag) {
243 
244                 if (identifierBag == null) {
245                         return null;
246                 }
247                 IdentifierBag r = new IdentifierBag();
248                 r.getKeyedReference().addAll(MapKeyedReference(identifierBag.getKeyedReference()));
249                 return r;
250         }
251 
252         /**
253          * limitation, only the first overview doc is mapped
254          *
255          * @param overviewDoc
256          * @return overdoc or null
257          */
258         private static OverviewDoc mapOverviewDoc(org.uddi.api_v2.OverviewDoc overviewDoc) {
259                 if (overviewDoc == null) {
260                         return null;
261                 }
262                 OverviewDoc r = new OverviewDoc();
263                 r.getDescription().addAll(MapDescription(overviewDoc.getDescription()));
264                 if (overviewDoc.getOverviewURL() != null) {
265                         r.setOverviewURL(new OverviewURL());
266                         overviewDoc.getDescription();
267                         r.getOverviewURL().setValue(overviewDoc.getOverviewURL());
268                 }
269                 return r;
270         }
271 
272         private static AccessPoint mapAccessPoint(org.uddi.api_v2.AccessPoint accessPoint) {
273                 if (accessPoint == null) {
274                         return null;
275                 }
276                 return new AccessPoint(accessPoint.getValue(), 
277                         mapURLType(accessPoint.getValue(),
278                                 accessPoint.getURLType()));
279         }
280 
281         private static HostingRedirector mapHostingRedir(org.uddi.api_v2.HostingRedirector hostingRedirector) {
282                 if (hostingRedirector == null) {
283                         return null;
284                 }
285                 HostingRedirector r = new HostingRedirector();
286                 r.setBindingKey(hostingRedirector.getBindingKey());
287                 return r;
288         }
289 
290         private static TModelInstanceDetails MapTModelInstanceDetails(org.uddi.api_v2.TModelInstanceDetails tModelInstanceDetails) {
291                 if (tModelInstanceDetails == null || tModelInstanceDetails.getTModelInstanceInfo()==null || tModelInstanceDetails.getTModelInstanceInfo().isEmpty()) {
292                         return null;
293                 }
294                 TModelInstanceDetails r = new TModelInstanceDetails();
295                 r.getTModelInstanceInfo().addAll(MapTModelInstanceInfo(tModelInstanceDetails.getTModelInstanceInfo()));
296                 return r;
297         }
298 
299         private static List<KeyedReference> MapKeyedReference(List<org.uddi.api_v2.KeyedReference> keyedReference) {
300                 List<KeyedReference> r = new ArrayList<KeyedReference>();
301                 if (keyedReference == null) {
302                         return r;
303                 }
304                 for (int i = 0; i < keyedReference.size(); i++) {
305                         r.add(new KeyedReference(keyedReference.get(i).getTModelKey(), keyedReference.get(i).getKeyName(), keyedReference.get(i).getKeyValue()));
306                 }
307                 return r;
308         }
309 
310         private static String mapURLType(String url, org.uddi.api_v2.URLType type) {
311                 if (url == null) {
312                         return null;
313                 }
314                 if (type!=null)
315                         return type.name();
316                 return null;
317         }
318 
319         private static List<TModelInstanceInfo> MapTModelInstanceInfo(List<org.uddi.api_v2.TModelInstanceInfo> tModelInstanceInfo) {
320                 List<TModelInstanceInfo> r = new ArrayList<TModelInstanceInfo>();
321                 if (tModelInstanceInfo == null) {
322                         return r;
323                 }
324                 for (int i = 0; i < tModelInstanceInfo.size(); i++) {
325                         TModelInstanceInfo t = new TModelInstanceInfo();
326                         t.setTModelKey(tModelInstanceInfo.get(i).getTModelKey());
327                         t.getDescription().addAll(MapDescription(tModelInstanceInfo.get(i).getDescription()));
328                         if (tModelInstanceInfo.get(i).getInstanceDetails() != null) {
329                                 t.setInstanceDetails(new InstanceDetails());
330                                 t.getInstanceDetails().getDescription().addAll(MapDescription(tModelInstanceInfo.get(i).getInstanceDetails().getDescription()));
331                                 t.getInstanceDetails().setInstanceParms(tModelInstanceInfo.get(i).getInstanceDetails().getInstanceParms());
332                                 t.getInstanceDetails().getOverviewDoc().add(mapOverviewDoc(tModelInstanceInfo.get(i).getInstanceDetails().getOverviewDoc()));
333                         }
334                         r.add(t);
335                 }
336                 return r;
337         }
338 
339         public static org.uddi.api_v3.BindingDetail MapBindingDetail(org.uddi.api_v2.BindingDetail findBinding) {
340                 org.uddi.api_v3.BindingDetail r = new org.uddi.api_v3.BindingDetail();
341                 for (int i = 0; i < findBinding.getBindingTemplate().size(); i++) {
342                         r.getBindingTemplate().addAll(MapBinding(findBinding.getBindingTemplate()));
343                 }
344                 r.setTruncated(findBinding.getTruncated() == Truncated.TRUE);
345                 return r;
346         }
347 
348         public static BusinessList MapBusinessList(org.uddi.api_v2.BusinessList findBinding) {
349                 org.uddi.api_v3.BusinessList r = new org.uddi.api_v3.BusinessList();
350                 r.setListDescription(new ListDescription());
351                 r.getListDescription().setActualCount(0);
352                 r.getListDescription().setIncludeCount(0);
353                 r.getListDescription().setListHead(0);
354                 if (findBinding.getBusinessInfos() != null) {
355                         r.getListDescription().setIncludeCount(findBinding.getBusinessInfos().getBusinessInfo().size());
356                         r.getListDescription().setActualCount(findBinding.getBusinessInfos().getBusinessInfo().size());
357                         r.setBusinessInfos(new BusinessInfos());
358                         r.getBusinessInfos().getBusinessInfo().addAll(MapBusinessInfo(findBinding.getBusinessInfos().getBusinessInfo()));
359 
360                 }
361                 r.setTruncated(findBinding.getTruncated() == Truncated.TRUE);
362                 return r;
363         }
364 
365         public static DispositionReportFaultMessage MapException(DispositionReport ex) {
366                 org.uddi.api_v3.DispositionReport r = new org.uddi.api_v3.DispositionReport();
367                 r.setTruncated(ex.getFaultInfo().getTruncated() == Truncated.TRUE);
368                 r.getResult().addAll(MapResult(ex.getFaultInfo().getResult()));
369 
370                 DispositionReportFaultMessage x = new DispositionReportFaultMessage(ex.getMessage(), r);
371                 return x;
372         }
373 
374         public static RelatedBusinessesList MapRelatedBusinessesList(org.uddi.api_v2.RelatedBusinessesList findRelatedBusinesses) {
375                 if (findRelatedBusinesses == null) {
376                         return null;
377                 }
378                 RelatedBusinessesList r = new RelatedBusinessesList();
379                 r.setTruncated(findRelatedBusinesses.getTruncated() == Truncated.TRUE);
380                 r.setBusinessKey(findRelatedBusinesses.getBusinessKey());
381 
382                 if (findRelatedBusinesses.getRelatedBusinessInfos() != null) {
383                         r.setRelatedBusinessInfos(new RelatedBusinessInfos());
384                         for (int i = 0; i < findRelatedBusinesses.getRelatedBusinessInfos().getRelatedBusinessInfo().size(); i++) {
385                                 RelatedBusinessInfo x = new RelatedBusinessInfo();
386                                 x.setBusinessKey(findRelatedBusinesses.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getBusinessKey());
387                                 x.getDescription().addAll(MapDescription(findRelatedBusinesses.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getDescription()));
388                                 x.getName().addAll(MapName(findRelatedBusinesses.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getName()));
389                                 x.getSharedRelationships().addAll(MapSharedRelationship(findRelatedBusinesses.getRelatedBusinessInfos().getRelatedBusinessInfo().get(i).getSharedRelationships()));
390                                 r.getRelatedBusinessInfos().getRelatedBusinessInfo().add(x);
391                         }
392                 }
393                 return r;
394         }
395 
396         public static ServiceList MapServiceList(org.uddi.api_v2.ServiceList serviceDetail) {
397                 if (serviceDetail == null) {
398                         return null;
399                 }
400                 ServiceList r = new ServiceList();
401                 r.setListDescription(new ListDescription());
402                 r.getListDescription().setActualCount(0);
403                 r.getListDescription().setIncludeCount(0);
404                 r.getListDescription().setListHead(0);
405 
406                 if (serviceDetail.getServiceInfos() != null) {
407                         r.setServiceInfos(new ServiceInfos());
408                         r.getListDescription().setIncludeCount(serviceDetail.getServiceInfos().getServiceInfo().size());
409                         r.getListDescription().setActualCount(serviceDetail.getServiceInfos().getServiceInfo().size());
410                         for (int i = 0; i < serviceDetail.getServiceInfos().getServiceInfo().size(); i++) {
411                                 ServiceInfo x = new ServiceInfo();
412                                 x.setBusinessKey(serviceDetail.getServiceInfos().getServiceInfo().get(i).getBusinessKey());
413                                 x.setServiceKey(serviceDetail.getServiceInfos().getServiceInfo().get(i).getServiceKey());
414                                 x.getName().addAll(MapName(serviceDetail.getServiceInfos().getServiceInfo().get(i).getName()));
415                                 r.getServiceInfos().getServiceInfo().add(x);
416                         }
417                 }
418                 r.setTruncated(serviceDetail.getTruncated() == Truncated.TRUE);
419                 return r;
420         }
421 
422         public static BusinessDetail MapBusinessDetail(org.uddi.api_v2.BusinessDetail businessDetail) {
423                 if (businessDetail == null) {
424                         return null;
425                 }
426                 BusinessDetail r = new BusinessDetail();
427                 for (int i = 0; i < businessDetail.getBusinessEntity().size(); i++) {
428                         r.getBusinessEntity().add(MapBusiness(businessDetail.getBusinessEntity().get(i)));
429                 }
430                 r.setTruncated(businessDetail.getTruncated() == Truncated.TRUE);
431                 return r;
432         }
433 
434         public static ServiceDetail MapServiceDetail(org.uddi.api_v2.ServiceDetail serviceDetail) {
435                 if (serviceDetail == null) {
436                         return null;
437                 }
438                 ServiceDetail r = new ServiceDetail();
439                 for (int i = 0; i < serviceDetail.getBusinessService().size(); i++) {
440                         r.getBusinessService().add(MapService(serviceDetail.getBusinessService().get(i)));
441                 }
442                 r.setTruncated(serviceDetail.getTruncated() == Truncated.TRUE);
443                 return r;
444         }
445 
446         public static TModelDetail MapTModelDetail(org.uddi.api_v2.TModelDetail tModelDetail) {
447                 if (tModelDetail == null) {
448                         return null;
449                 }
450                 TModelDetail r = new TModelDetail();
451                 for (int i = 0; i < tModelDetail.getTModel().size(); i++) {
452                         r.getTModel().add(MapTModel(tModelDetail.getTModel().get(i)));
453                 }
454                 r.setTruncated(tModelDetail.getTruncated() == Truncated.TRUE);
455                 return r;
456         }
457 
458         public static TModelList MapTModelList(org.uddi.api_v2.TModelList findTModel) {
459                 org.uddi.api_v3.TModelList r = new org.uddi.api_v3.TModelList();
460                 r.setListDescription(new ListDescription());
461                 r.getListDescription().setActualCount(0);
462                 r.getListDescription().setIncludeCount(0);
463                 r.getListDescription().setListHead(0);
464 
465                 if (findTModel.getTModelInfos() != null && !findTModel.getTModelInfos().getTModelInfo().isEmpty()) {
466                         r.setTModelInfos(new TModelInfos());
467                         r.getListDescription().setIncludeCount(findTModel.getTModelInfos().getTModelInfo().size());
468                         r.getListDescription().setActualCount(findTModel.getTModelInfos().getTModelInfo().size());
469                         for (int i = 0; i < findTModel.getTModelInfos().getTModelInfo().size(); i++) {
470                                 TModelInfo x = new TModelInfo();
471                                 x.setName(new Name(findTModel.getTModelInfos().getTModelInfo().get(i).getName().getValue(), findTModel.getTModelInfos().getTModelInfo().get(i).getName().getLang()));
472                                 x.setTModelKey(findTModel.getTModelInfos().getTModelInfo().get(i).getTModelKey());
473 
474                                 r.getTModelInfos().getTModelInfo().add(x);
475                         }
476 
477                 }
478                 r.setTruncated(findTModel.getTruncated() == Truncated.TRUE);
479                 return r;
480         }
481 
482         public static List<PublisherAssertion> MapListPublisherAssertion(List<org.uddi.api_v2.PublisherAssertion> publisherAssertions) {
483                 List<PublisherAssertion> r = new ArrayList<PublisherAssertion>();
484                 if (publisherAssertions == null) {
485                         return r;
486                 }
487                 for (int i = 0; i < publisherAssertions.size(); i++) {
488                         PublisherAssertion x = new PublisherAssertion();
489                         x.setFromKey(publisherAssertions.get(i).getFromKey());
490                         x.setToKey(publisherAssertions.get(i).getToKey());
491                         if (publisherAssertions.get(i).getKeyedReference() != null) {
492                                 x.setKeyedReference(new KeyedReference(publisherAssertions.get(i).getKeyedReference().getTModelKey(),
493                                      publisherAssertions.get(i).getKeyedReference().getKeyName(),
494                                      publisherAssertions.get(i).getKeyedReference().getKeyValue()));
495                         }
496                         r.add(x);
497                 }
498                 return r;
499         }
500 
501         public static List<PublisherAssertion> MapListPublisherAssertion(org.uddi.api_v2.PublisherAssertions publisherAssertions) {
502                 List<PublisherAssertion> r = new ArrayList<PublisherAssertion>();
503                 if (publisherAssertions == null) {
504                         return r;
505                 }
506 
507                 r.addAll(MapListPublisherAssertion(publisherAssertions.getPublisherAssertion()));
508 
509                 return r;
510         }
511 
512         public static RegisteredInfo MapListRegisteredInfo(org.uddi.api_v2.RegisteredInfo registeredInfo) {
513                 if (registeredInfo == null) {
514                         return null;
515                 }
516                 RegisteredInfo r = new RegisteredInfo();
517                 if (registeredInfo.getBusinessInfos() != null) {
518                         r.setBusinessInfos(new BusinessInfos());
519                         r.getBusinessInfos().getBusinessInfo().addAll(MapBusinessInfo(registeredInfo.getBusinessInfos().getBusinessInfo()));
520                 }
521                 if (registeredInfo.getTModelInfos() != null) {
522                         r.setTModelInfos(new TModelInfos());
523                         for (int i = 0; i < registeredInfo.getTModelInfos().getTModelInfo().size(); i++) {
524                                 TModelInfo x = new TModelInfo();
525                                 x.setTModelKey(registeredInfo.getTModelInfos().getTModelInfo().get(i).getTModelKey());
526                                 x.setName(new Name(registeredInfo.getTModelInfos().getTModelInfo().get(i).getName().getValue(),
527                                      registeredInfo.getTModelInfos().getTModelInfo().get(i).getName().getValue()));
528                                 r.getTModelInfos().getTModelInfo().add(x);
529                         }
530 
531                 }
532                 r.setTruncated(registeredInfo.getTruncated() == Truncated.TRUE);
533                 return r;
534         }
535 
536         private static List< BusinessInfo> MapBusinessInfo(List<org.uddi.api_v2.BusinessInfo> businessInfo) {
537 
538                 List< BusinessInfo> r = new ArrayList<BusinessInfo>();
539                 if (businessInfo == null) {
540                         return r;
541                 }
542                 for (int i = 0; i < businessInfo.size(); i++) {
543                         BusinessInfo x = new BusinessInfo();
544                         x.setBusinessKey(businessInfo.get(i).getBusinessKey());
545                         x.setServiceInfos(MapServiceInfo(businessInfo.get(i).getServiceInfos()));
546                         x.getName().addAll(MapName(businessInfo.get(i).getName()));
547                         x.getDescription().addAll(MapDescription(businessInfo.get(i).getDescription()));
548                         r.add(x);
549                 }
550 
551                 return r;
552         }
553 
554         private static ServiceInfos MapServiceInfo(org.uddi.api_v2.ServiceInfos serviceInfos) {
555                 if (serviceInfos == null) {
556                         return null;
557                 }
558                 ServiceInfos r = new ServiceInfos();
559                 for (int i = 0; i < serviceInfos.getServiceInfo().size(); i++) {
560                         ServiceInfo x = new ServiceInfo();
561                         x.setBusinessKey(serviceInfos.getServiceInfo().get(i).getBusinessKey());
562                         x.setServiceKey(serviceInfos.getServiceInfo().get(i).getServiceKey());
563                         x.getName().addAll(MapName(serviceInfos.getServiceInfo().get(i).getName()));
564                         r.getServiceInfo().add(x);
565                 }
566                 return r;
567         }
568 
569         private static List<Result> MapResult(List<org.uddi.api_v2.Result> result) {
570                 List<Result> r = new ArrayList<Result>();
571                 if (result == null) {
572                         return r;
573                 }
574                 for (int i = 0; i < result.size(); i++) {
575                         Result x = new Result();
576                         x.setErrno(result.get(i).getErrno());
577                         if (result.get(i).getKeyType() != null) {
578                                 switch (result.get(i).getKeyType()) {
579                                         case BINDING_KEY:
580                                                 x.setKeyType(KeyType.BINDING_KEY);
581                                                 break;
582                                         case BUSINESS_KEY:
583                                                 x.setKeyType(KeyType.BUSINESS_KEY);
584                                                 break;
585                                         case SERVICE_KEY:
586                                                 x.setKeyType(KeyType.SERVICE_KEY);
587                                                 break;
588                                         case T_MODEL_KEY:
589                                                 x.setKeyType(KeyType.T_MODEL_KEY);
590                                                 break;
591                                 }
592                         }
593                         if (result.get(i).getErrInfo() != null) {
594                                 x.setErrInfo(new ErrInfo());
595                                 x.getErrInfo().setErrCode(result.get(i).getErrInfo().getErrCode());
596                                 x.getErrInfo().setValue(result.get(i).getErrInfo().getValue());
597                         }
598                         r.add(x);
599                 }
600                 return r;
601         }
602 
603         public static DispositionReportFaultMessage MapException(SOAPFaultException ex) {
604                 org.uddi.api_v3.DispositionReport r = new org.uddi.api_v3.DispositionReport();
605                 r.setTruncated(false);
606                 r.getResult().addAll(MapFault(ex.getFault()));
607                 DispositionReportFaultMessage x = new DispositionReportFaultMessage(ex.getMessage(), r);
608                 return x;
609         }
610 
611         private static List<Result> MapFault(SOAPFault result) {
612                 List<Result> r = new ArrayList<Result>();
613                 if (result == null) {
614                         return r;
615                 }
616                 if (result.getDetail() != null) {
617                         while (result.getDetail().getDetailEntries().hasNext()) {
618                                 Object next = result.getDetail().getDetailEntries().next();
619                                 if (next instanceof DispositionReport) {
620 
621                                         DispositionReport z = (DispositionReport) next;
622                                         r.addAll(MapResult(z.getFaultInfo().getResult()));
623 
624                                 }
625                                 logger.warn("unable to parse fault detail, type:" + next.getClass().getCanonicalName() + " " + next.toString());
626                         }
627                 }
628                 return r;
629         }
630         private static Log logger = LogFactory.getLog(MapUDDIv2Tov3.class);
631 
632         public static FindBinding MapFindBinding(org.uddi.api_v2.FindBinding body) {
633                 if (body == null) {
634                         return null;
635                 }
636                 FindBinding r = new FindBinding();
637                 r.setServiceKey(body.getServiceKey());
638                 r.setFindQualifiers(MapFindQualifiers(body.getFindQualifiers(), true));
639                 r.setMaxRows(body.getMaxRows());
640                 r.setTModelBag(MapTModelBag(body.getTModelBag()));
641                 return r;
642 
643         }
644 
645         private static TModelBag MapTModelBag(org.uddi.api_v2.TModelBag tModelBag) {
646                 if (tModelBag == null || tModelBag.getTModelKey().isEmpty()) {
647                         return null;
648                 }
649                 TModelBag r = new TModelBag();
650                 r.getTModelKey().addAll(tModelBag.getTModelKey());
651                 return r;
652         }
653 
654         private static FindQualifiers MapFindQualifiers(org.uddi.api_v2.FindQualifiers findQualifiers, boolean isBinding) {
655                 if (findQualifiers == null || findQualifiers.getFindQualifier().isEmpty()) {
656                         return null;
657                 }
658                 FindQualifiers r = new FindQualifiers();
659                 for (int i = 0; i < findQualifiers.getFindQualifier().size(); i++) {
660                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:68DE9E80-AD09-469D-8A37-088422BFBC36")) {
661                                 r.getFindQualifier().add(UDDIConstants.TRANSPORT_HTTP);
662                         }
663                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:93335D49-3EFB-48A0-ACEA-EA102B60DDC6")) {
664                                 r.getFindQualifier().add(UDDIConstants.TRANSPORT_EMAIL);
665                         }
666                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:5FCF5CD0-629A-4C50-8B16-F94E9CF2A674")) {
667                                 r.getFindQualifier().add(UDDIConstants.TRANSPORT_FTP);
668                         }
669                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:1A2B00BE-6E2C-42F5-875B-56F32686E0E7")) {
670                                 r.getFindQualifier().add(UDDIConstants.TRANSPORT_FAX);
671                         }
672                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:38E12427-5536-4260-A6F9-B5B530E63A07")) {
673                                 r.getFindQualifier().add(UDDIConstants.TRANSPORT_POTS);
674                         }
675                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:E59AE320-77A5-11D5-B898-0004AC49CC1E")) {
676                                 r.getFindQualifier().add(UDDIConstants.IS_REPLACED_BY);
677                         }
678                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:4064C064-6D14-4F35-8953-9652106476A9")) {
679                                 r.getFindQualifier().add(UDDIConstants.OWNING_BUSINESS);
680                         }
681                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:807A2C6A-EE22-470D-ADC7-E0424A337C03")) {
682                                 r.getFindQualifier().add(UDDIConstants.RELATIONSHIPS);
683                         }
684                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:327A56F0-3299-4461-BC23-5CD513E95C55")) {
685                                 r.getFindQualifier().add("uddi:uddi.org:categorization:nodes");
686                         }
687                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:A035A07C-F362-44dd-8F95-E2B134BF43B4")) {
688                                 r.getFindQualifier().add("uddi:uddi.org:categorization:general_keywords");
689                         }
690                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4")) {
691                                 r.getFindQualifier().add("uddi:uddi.org:categorization:types");
692                         }
693                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase("exactNameMatch")) {
694                                 r.getFindQualifier().add(UDDIConstants.EXACT_MATCH);
695                         }
696                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.EXACT_MATCH)) {
697                                 r.getFindQualifier().add(UDDIConstants.EXACT_MATCH);
698                         }
699                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.CASE_SENSITIVE_MATCH)) {
700                                 r.getFindQualifier().add("caseSensitiveMatch");
701                         }
702                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.OR_ALL_KEYS)) {
703                                 r.getFindQualifier().add("orAllKeys");
704                         }
705                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.OR_LIKE_KEYS)) {
706                                 r.getFindQualifier().add("orLikeKeys");
707                         }
708                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.AND_ALL_KEYS)) {
709                                 r.getFindQualifier().add("andAllKeys");
710                         }
711                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.SORT_BY_DATE_ASC)) {
712                                 r.getFindQualifier().add(UDDIConstants.SORT_BY_DATE_ASC);
713                         }
714                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.SORT_BY_DATE_DESC)) {
715                                 r.getFindQualifier().add(UDDIConstants.SORT_BY_DATE_DESC);
716                         }
717 
718                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.SORT_BY_NAME_ASC)) {
719                                 r.getFindQualifier().add(UDDIConstants.SORT_BY_NAME_ASC);
720                         }
721                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.SORT_BY_NAME_DESC)) {
722                                 r.getFindQualifier().add(UDDIConstants.SORT_BY_NAME_DESC);
723                         }
724                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.SERVICE_SUBSET)) {
725                                 r.getFindQualifier().add(UDDIConstants.SERVICE_SUBSET);
726                         }
727                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.COMBINE_CATEGORY_BAGS)) {
728                                 r.getFindQualifier().add(UDDIConstants.COMBINE_CATEGORY_BAGS);
729                         }
730                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIv2Constants.exactNameMatch)) {
731                                 r.getFindQualifier().add(UDDIConstants.EXACT_MATCH);
732                         }
733                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.APPROXIMATE_MATCH)) {
734                                 r.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
735                         }
736                         if (findQualifiers.getFindQualifier().get(i).equalsIgnoreCase(UDDIConstants.APPROXIMATE_MATCH_TMODEL)) {
737                                 r.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
738                         }
739                         
740                 }
741                 //default behavior of v2, caseInsensitive, sortByNameAsc or sortByDateAsc, approximateMatch
742                 if (!r.getFindQualifier().contains(UDDIConstants.CASE_INSENSITIVE_MATCH) &&
743                      !r.getFindQualifier().contains(UDDIConstants.CASE_INSENSITIVE_MATCH_TMODEL) &&
744                      !r.getFindQualifier().contains(UDDIConstants.CASE_SENSITIVE_MATCH) && 
745                      !r.getFindQualifier().contains(UDDIConstants.EXACT_MATCH) &&
746                      !isBinding)
747                         
748                      r.getFindQualifier().add(UDDIConstants.CASE_INSENSITIVE_MATCH);
749                 
750                 if (!r.getFindQualifier().contains(UDDIConstants.APPROXIMATE_MATCH) &&
751                      !r.getFindQualifier().contains(UDDIConstants.APPROXIMATE_MATCH_TMODEL) &&
752                      !r.getFindQualifier().contains(UDDIConstants.EXACT_MATCH) &&
753                      !isBinding)
754                      r.getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
755                 //dedup
756                 HashSet<String> s = new HashSet<String>(r.getFindQualifier());
757                 r.getFindQualifier().clear();
758                 r.getFindQualifier().addAll(s);
759                 return r;
760         }
761 
762         public static FindBusiness MapFindBusiness(org.uddi.api_v2.FindBusiness body) {
763                 if (body == null) {
764                         return null;
765                 }
766                 FindBusiness r = new FindBusiness();
767                 r.setCategoryBag(MapCategoryBag(body.getCategoryBag()));
768                 r.setDiscoveryURLs(MapDiscoveryURLs(body.getDiscoveryURLs()));
769                 r.setIdentifierBag(MapIdentBag(body.getIdentifierBag()));
770                 r.setFindQualifiers(MapFindQualifiers(body.getFindQualifiers(), false));
771                 r.setTModelBag(MapTModelBag(body.getTModelBag()));
772                 r.setMaxRows(body.getMaxRows());
773                 r.getName().addAll(MapName(body.getName()));
774                 if (ContainsWildCard(r.getName())) {
775                         r.setFindQualifiers(AddApproximateMatch(r.getFindQualifiers()));
776                 }
777                 return r;
778         }
779 
780         private static org.uddi.api_v3.FindQualifiers AddApproximateMatch(org.uddi.api_v3.FindQualifiers findQualifiers) {
781                 if (findQualifiers == null) {
782                         findQualifiers = new org.uddi.api_v3.FindQualifiers();
783                 }
784                 Set<String> s = new HashSet<String>(findQualifiers.getFindQualifier());
785                 s.add(UDDIConstants.APPROXIMATE_MATCH);
786                 findQualifiers.getFindQualifier().clear();
787                 findQualifiers.getFindQualifier().addAll(s);
788                 return findQualifiers;
789         }
790 
791         private static boolean ContainsWildCard(List<org.uddi.api_v3.Name> name) {
792                 for (int i = 0; i < name.size(); i++) {
793                         if (name.get(i).getValue() != null && name.get(i).getValue().contains(UDDIConstants.WILDCARD)) {
794                                 return true;
795                         }
796                         if (name.get(i).getValue() != null && name.get(i).getValue().contains(UDDIConstants.WILDCARD_CHAR)) {
797                                 return true;
798                         }
799                         if (name.get(i).getLang() != null
800                              && name.get(i).getLang().contains(UDDIConstants.WILDCARD)) {
801                                 return true;
802                         }
803                         if (name.get(i).getLang() != null
804                              && name.get(i).getLang().contains(UDDIConstants.WILDCARD_CHAR)) {
805                                 return true;
806                         }
807                 }
808                 return false;
809         }
810 
811         private static DiscoveryURLs MapDiscoveryURLs(org.uddi.api_v2.DiscoveryURLs discoveryURLs) {
812                 if (discoveryURLs == null) {
813                         return null;
814                 }
815                 DiscoveryURLs r = new DiscoveryURLs();
816                 for (int i = 0; i < discoveryURLs.getDiscoveryURL().size(); i++) {
817                         DiscoveryURL x = new DiscoveryURL(discoveryURLs.getDiscoveryURL().get(i).getUseType(), discoveryURLs.getDiscoveryURL().get(i).getValue());
818                         r.getDiscoveryURL().add(x);
819                 }
820                 return r;
821         }
822 
823         public static FindRelatedBusinesses MapFindRelatedBusiness(org.uddi.api_v2.FindRelatedBusinesses body) {
824                 if (body == null) {
825                         return null;
826                 }
827                 FindRelatedBusinesses r = new FindRelatedBusinesses();
828                 r.setBusinessKey(body.getBusinessKey());
829                 r.setFindQualifiers(MapFindQualifiers(body.getFindQualifiers(),false));
830                 if (body.getKeyedReference() != null) {
831                         r.setKeyedReference(new KeyedReference(body.getKeyedReference().getTModelKey(), body.getKeyedReference().getKeyName(), body.getKeyedReference().getKeyValue()));
832                 }
833                 r.setMaxRows(body.getMaxRows());
834                 return r;
835         }
836 
837         public static FindService MapFindService(org.uddi.api_v2.FindService body) {
838                 if (body == null) {
839                         return null;
840                 }
841                 FindService r = new FindService();
842                 r.setBusinessKey(body.getBusinessKey());
843                 r.setCategoryBag(MapCategoryBag(body.getCategoryBag()));
844                 r.setFindQualifiers(MapFindQualifiers(body.getFindQualifiers(),false));
845                 r.setMaxRows(body.getMaxRows());
846                 r.setTModelBag(MapTModelBag(body.getTModelBag()));
847                 r.getName().addAll(MapName(body.getName()));
848                 if (ContainsWildCard(r.getName())) {
849                         r.setFindQualifiers(AddApproximateMatch(r.getFindQualifiers()));
850                 }
851                 return r;
852 
853         }
854 
855         public static FindTModel MapFindTModel(org.uddi.api_v2.FindTModel body) {
856                 if (body == null) {
857                         return null;
858                 }
859                 FindTModel r = new FindTModel();
860                 r.setCategoryBag(MapCategoryBag(body.getCategoryBag()));
861                 r.setFindQualifiers(MapFindQualifiers(body.getFindQualifiers(),false));
862                 r.setMaxRows(body.getMaxRows());
863                 if (body.getName() != null) {
864                         r.setName(new Name(body.getName().getValue(), body.getName().getLang()));
865                 }
866                 if (ContainsWildCardSingle(r.getName())) {
867                         r.setFindQualifiers(AddApproximateMatch(r.getFindQualifiers()));
868                 }
869                 return r;
870         }
871 
872         public static GetBusinessDetail MapGetBusinessDetailExt(GetBusinessDetailExt body) {
873                 if (body == null) {
874                         return null;
875                 }
876                 GetBusinessDetail r = new GetBusinessDetail();
877                 r.getBusinessKey().addAll(body.getBusinessKey());
878                 return r;
879         }
880 
881         public static GetServiceDetail MapGetServiceDetail(org.uddi.api_v2.GetServiceDetail body) {
882                 if (body == null) {
883                         return null;
884                 }
885                 GetServiceDetail r = new GetServiceDetail();
886                 r.getServiceKey().addAll(body.getServiceKey());
887                 return r;
888         }
889 
890         public static org.uddi.api_v3.GetTModelDetail MapGetTModelDetail(GetTModelDetail body) {
891                 if (body == null) {
892                         return null;
893                 }
894                 org.uddi.api_v3.GetTModelDetail r = new org.uddi.api_v3.GetTModelDetail();
895                 r.getTModelKey().addAll(body.getTModelKey());
896                 return r;
897         }
898 
899         public static GetBindingDetail MapGetBindingDetail(org.uddi.api_v2.GetBindingDetail body) {
900                 if (body == null) {
901                         return null;
902                 }
903                 GetBindingDetail r = new GetBindingDetail();
904                 r.getBindingKey().addAll(body.getBindingKey());
905                 return r;
906         }
907 
908         public static GetBusinessDetail MapGetBusinessDetail(org.uddi.api_v2.GetBusinessDetail body) {
909                 if (body == null) {
910                         return null;
911                 }
912                 GetBusinessDetail r = new GetBusinessDetail();
913                 r.getBusinessKey().addAll(body.getBusinessKey());
914                 return r;
915         }
916 
917         private static List<SharedRelationships> MapSharedRelationship(List<org.uddi.api_v2.SharedRelationships> sharedRelationships) {
918                 if (sharedRelationships == null) {
919                         return null;
920                 }
921                 List<SharedRelationships> r = new ArrayList<SharedRelationships>();
922                 for (int i = 0; i < sharedRelationships.size(); i++) {
923                         SharedRelationships x = new SharedRelationships();
924 
925                         switch (sharedRelationships.get(i).getDirection()) {
926                                 case FROM_KEY:
927                                         x.setDirection(Direction.FROM_KEY);
928                                         break;
929                                 case TO_KEY:
930                                         x.setDirection(Direction.TO_KEY);
931                                         break;
932                         }
933                         x.getKeyedReference().addAll(MapKeyedReference(sharedRelationships.get(i).getKeyedReference()));
934                         r.add(x);
935                 }
936                 return r;
937         }
938 
939         public static DeleteBinding MapDeleteBinding(org.uddi.api_v2.DeleteBinding body) {
940                 if (body == null) {
941                         return null;
942                 }
943                 DeleteBinding r = new DeleteBinding();
944                 r.setAuthInfo(body.getAuthInfo());
945                 r.getBindingKey().addAll(body.getBindingKey());
946                 return r;
947         }
948 
949         public static DeleteBusiness MapDeleteBusiness(org.uddi.api_v2.DeleteBusiness body) {
950                 if (body == null) {
951                         return null;
952                 }
953                 DeleteBusiness r = new DeleteBusiness();
954                 r.setAuthInfo(body.getAuthInfo());
955                 r.getBusinessKey().addAll(body.getBusinessKey());
956                 return r;
957         }
958 
959         public static DeletePublisherAssertions MapDeletePublisherAssertion(org.uddi.api_v2.DeletePublisherAssertions body) {
960                 if (body == null) {
961                         return null;
962                 }
963                 DeletePublisherAssertions r = new DeletePublisherAssertions();
964                 r.setAuthInfo(body.getAuthInfo());
965                 r.getPublisherAssertion().addAll(MapListPublisherAssertion(body.getPublisherAssertion()));
966                 return r;
967         }
968 
969         public static DeleteService MapDeleteService(org.uddi.api_v2.DeleteService body) {
970                 if (body == null) {
971                         return null;
972                 }
973                 DeleteService r = new DeleteService();
974                 r.setAuthInfo(body.getAuthInfo());
975                 r.getServiceKey().addAll(body.getServiceKey());
976                 return r;
977         }
978 
979         public static DeleteTModel MapDeleteTModel(org.uddi.api_v2.DeleteTModel body) {
980                 if (body == null) {
981                         return null;
982                 }
983                 DeleteTModel r = new DeleteTModel();
984                 r.setAuthInfo(body.getAuthInfo());
985                 r.getTModelKey().addAll(body.getTModelKey());
986                 return r;
987         }
988 
989         public static SaveTModel MapSaveTModel(org.uddi.api_v2.SaveTModel body) {
990                 if (body == null) {
991                         return null;
992                 }
993                 SaveTModel r = new SaveTModel();
994                 r.setAuthInfo(body.getAuthInfo());
995                 for (int i = 0; i < body.getTModel().size(); i++) {
996                         r.getTModel().add(MapTModel(body.getTModel().get(i)));
997                 }
998                 return r;
999         }
1000 
1001         public static SaveService MapSaveService(org.uddi.api_v2.SaveService body) {
1002                 if (body == null) {
1003                         return null;
1004                 }
1005                 SaveService r = new SaveService();
1006                 r.setAuthInfo(body.getAuthInfo());
1007                 for (int i = 0; i < body.getBusinessService().size(); i++) {
1008                         r.getBusinessService().add(MapService(body.getBusinessService().get(i)));
1009                 }
1010                 return r;
1011         }
1012 
1013         public static SaveBusiness MapSaveBusiness(org.uddi.api_v2.SaveBusiness body) {
1014                 if (body == null) {
1015                         return null;
1016                 }
1017                 SaveBusiness r = new SaveBusiness();
1018                 r.setAuthInfo(body.getAuthInfo());
1019                 for (int i = 0; i < body.getBusinessEntity().size(); i++) {
1020                         r.getBusinessEntity().add(MapBusiness(body.getBusinessEntity().get(i)));
1021                 }
1022                 return r;
1023         }
1024 
1025         public static GetRegisteredInfo MapGetRegisteredInfo(org.uddi.api_v2.GetRegisteredInfo body) {
1026                 if (body == null) {
1027                         return null;
1028                 }
1029                 GetRegisteredInfo r = new GetRegisteredInfo();
1030                 r.setAuthInfo(body.getAuthInfo());
1031                 r.setInfoSelection(InfoSelection.ALL);
1032                 return r;
1033         }
1034 
1035         public static SaveBinding MapSaveBinding(org.uddi.api_v2.SaveBinding body) {
1036                 if (body == null) {
1037                         return null;
1038                 }
1039                 SaveBinding r = new SaveBinding();
1040                 r.setAuthInfo(body.getAuthInfo());
1041                 for (int i = 0; i < body.getBindingTemplate().size(); i++) {
1042                         r.getBindingTemplate().add(MapBinding(body.getBindingTemplate().get(i)));
1043                 }
1044                 return r;
1045         }
1046 
1047         public static List<PublisherAssertion> MapSetPublisherAssertions(SetPublisherAssertions body) {
1048                 if (body == null) {
1049                         return null;
1050                 }
1051                 return MapListPublisherAssertion(body.getPublisherAssertion());
1052         }
1053 
1054         private static boolean ContainsWildCardSingle(Name name) {
1055                 if (name != null) {
1056                         if (name.getValue() != null && name.getValue().contains(UDDIConstants.WILDCARD)) {
1057                                 return true;
1058                         }
1059                         if (name.getValue() != null && name.getValue().contains(UDDIConstants.WILDCARD_CHAR)) {
1060                                 return true;
1061                         }
1062                         if (name.getLang() != null && name.getLang().contains(UDDIConstants.WILDCARD)) {
1063                                 return true;
1064                         }
1065                         if (name.getLang() != null && name.getLang().contains(UDDIConstants.WILDCARD_CHAR)) {
1066                                 return true;
1067                         }
1068                 }
1069                 return false;
1070         }
1071 
1072         public static List<AssertionStatusItem> MapAssertionStatusItems(AssertionStatusReport assertionStatusReport) {
1073                 List<AssertionStatusItem> r = new ArrayList<AssertionStatusItem>();
1074                 if (assertionStatusReport == null) {
1075                         return r;
1076                 }
1077                 for (int i = 0; i < assertionStatusReport.getAssertionStatusItem().size(); i++) {
1078                         AssertionStatusItem x = new AssertionStatusItem();
1079                         x.setFromKey(assertionStatusReport.getAssertionStatusItem().get(i).getFromKey());
1080                         x.setToKey(assertionStatusReport.getAssertionStatusItem().get(i).getToKey());
1081                         x.setCompletionStatus(MapCompletionStatus(assertionStatusReport.getAssertionStatusItem().get(i).getCompletionStatus()));
1082 
1083                         x.setKeysOwned(MapKeysOwned(assertionStatusReport.getAssertionStatusItem().get(i).getKeysOwned()));
1084                         if (assertionStatusReport.getAssertionStatusItem().get(i).getKeyedReference() != null) {
1085                                 x.setKeyedReference(new KeyedReference(assertionStatusReport.getAssertionStatusItem().get(i).getKeyedReference().getTModelKey(),
1086                                      assertionStatusReport.getAssertionStatusItem().get(i).getKeyedReference().getKeyName(),
1087                                      assertionStatusReport.getAssertionStatusItem().get(i).getKeyedReference().getKeyValue()));
1088                         }
1089                         r.add(x);
1090                 }
1091                 return r;
1092         }
1093 
1094         private static KeysOwned MapKeysOwned(org.uddi.api_v2.KeysOwned keysOwned) {
1095                 if (keysOwned == null) {
1096                         return null;
1097                 }
1098                 KeysOwned r = new KeysOwned();
1099                 r.setFromKey(keysOwned.getFromKey());
1100                 r.setToKey(keysOwned.getToKey());
1101                 return r;
1102         }
1103 
1104         private static Contacts MapContacts(org.uddi.api_v2.Contacts contacts) {
1105                 if (contacts == null) {
1106                         return null;
1107                 }
1108                 Contacts c = new Contacts();
1109                 c.getContact().addAll(MapContactList(contacts.getContact()));
1110                 return c;
1111 
1112         }
1113 
1114         private static List<Contact> MapContactList(List<org.uddi.api_v2.Contact> contact) {
1115                 List<Contact> r = new ArrayList<Contact>();
1116                 if (contact == null) {
1117                         return r;
1118                 }
1119                 for (int i = 0; i < contact.size(); i++) {
1120                         Contact c = new Contact();
1121                         c.setUseType(contact.get(i).getUseType());
1122                         if (contact.get(i).getPersonName() != null) {
1123                                 c.getPersonName().add(new PersonName(contact.get(i).getPersonName(), null));
1124                         }
1125                         c.getAddress().addAll(MapAddress(contact.get(i).getAddress()));
1126                         c.getDescription().addAll(MapDescription(contact.get(i).getDescription()));
1127                         c.getEmail().addAll(MapEmail(contact.get(i).getEmail()));
1128                         c.getPhone().addAll(MapPhone(contact.get(i).getPhone()));
1129 
1130                         r.add(c);
1131                 }
1132                 return r;
1133         }
1134 
1135         private static Collection<? extends Address> MapAddress(List<org.uddi.api_v2.Address> address) {
1136                 List<Address> r = new ArrayList<Address>();
1137                 if (address == null) {
1138                         return r;
1139                 }
1140                 for (int i = 0; i < address.size(); i++) {
1141                         Address x = new Address();
1142                         x.setSortCode(address.get(i).getSortCode());
1143                         x.setTModelKey(address.get(i).getTModelKey());
1144                         x.setUseType(address.get(i).getUseType());
1145                         x.getAddressLine().addAll(MapAddressLine(address.get(i).getAddressLine()));
1146                         r.add(x);
1147                 }
1148                 return r;
1149 
1150         }
1151 
1152         private static Collection<? extends Email> MapEmail(List<org.uddi.api_v2.Email> email) {
1153                 List<Email> r = new ArrayList<Email>();
1154                 if (email == null) {
1155                         return r;
1156                 }
1157                 for (int i = 0; i < email.size(); i++) {
1158                         Email x = new Email();
1159                         x.setUseType(email.get(i).getUseType());
1160                         x.setValue(email.get(i).getValue());
1161                         r.add(x);
1162                 }
1163 
1164                 return r;
1165         }
1166 
1167         private static Collection<? extends Phone> MapPhone(List<org.uddi.api_v2.Phone> phone) {
1168                 List<Phone> r = new ArrayList<Phone>();
1169                 if (phone == null) {
1170                         return r;
1171                 }
1172                 for (int i = 0; i < phone.size(); i++) {
1173                         Phone x = new Phone();
1174                         x.setUseType(phone.get(i).getUseType());
1175                         x.setValue(phone.get(i).getValue());
1176                         r.add(x);
1177                 }
1178 
1179                 return r;
1180         }
1181 
1182         private static List<org.uddi.api_v3.AddressLine> MapAddressLine(List<org.uddi.api_v2.AddressLine> addressLine) {
1183                 List<org.uddi.api_v3.AddressLine> r = new ArrayList<org.uddi.api_v3.AddressLine>();
1184                 if (addressLine == null) {
1185                         return r;
1186                 }
1187                 for (int i = 0; i < addressLine.size(); i++) {
1188                         org.uddi.api_v3.AddressLine x = new org.uddi.api_v3.AddressLine();
1189                         x.setKeyName(addressLine.get(i).getKeyName());
1190                         x.setKeyValue(addressLine.get(i).getKeyValue());
1191                         x.setValue(addressLine.get(i).getValue());
1192                         r.add(x);
1193                 }
1194 
1195                 return r;
1196         }
1197 
1198         public static AddPublisherAssertions MapAddPublisherAssertions(org.uddi.api_v2.AddPublisherAssertions body) {
1199 
1200                 if (body == null) {
1201                         return null;
1202                 }
1203                 AddPublisherAssertions r = new AddPublisherAssertions();
1204                 r.setAuthInfo(body.getAuthInfo());
1205                 r.getPublisherAssertion().addAll(MapListPublisherAssertion(body.getPublisherAssertion()));
1206                 return r;
1207 
1208         }
1209 
1210         public static CompletionStatus MapCompletionStatus(String completionStatus) {
1211 
1212                 if ("status:complete".equalsIgnoreCase(completionStatus)) {
1213                         return (CompletionStatus.STATUS_COMPLETE);
1214                 } else if ("status:toKey_incomplete".equalsIgnoreCase(completionStatus)) {
1215                         return (CompletionStatus.STATUS_TO_KEY_INCOMPLETE);
1216                 } else if ("status:fromKey_incomplete".equalsIgnoreCase(completionStatus)) {
1217                         return (CompletionStatus.STATUS_FROM_KEY_INCOMPLETE);
1218                 } else {
1219                         return (CompletionStatus.STATUS_BOTH_INCOMPLETE);
1220                 }
1221 
1222         }
1223 
1224 }