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