This project has retired. For details please refer to its Attic page.
MappingApiToModel xref
View Javadoc
1   /*
2    * Copyright 2001-2008 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   */
17  package org.apache.juddi.mapping;
18  
19  import java.io.StringWriter;
20  import java.io.UnsupportedEncodingException;
21  import java.text.SimpleDateFormat;
22  import java.util.ArrayList;
23  import java.util.Date;
24  import java.util.GregorianCalendar;
25  import java.util.HashSet;
26  import java.util.List;
27  import javax.persistence.EntityManager;
28  import javax.xml.bind.JAXB;
29  import javax.xml.bind.JAXBElement;
30  import javax.xml.transform.dom.DOMResult;
31  import org.apache.commons.logging.Log;
32  import org.apache.commons.logging.LogFactory;
33  import org.apache.juddi.api.impl.AuthenticatedService;
34  import org.apache.juddi.jaxb.JAXBMarshaller;
35  import org.apache.juddi.model.Address;
36  import org.apache.juddi.model.BindingTemplate;
37  import org.apache.juddi.model.BusinessEntity;
38  import org.apache.juddi.model.BusinessService;
39  import org.apache.juddi.model.CanonicalizationMethod;
40  import org.apache.juddi.model.Contact;
41  import org.apache.juddi.model.ControlMessage;
42  import org.apache.juddi.model.Edge;
43  import org.apache.juddi.model.EdgeReceiverAlternate;
44  import org.apache.juddi.model.KeyDataValue;
45  import org.apache.juddi.model.KeyInfo;
46  import org.apache.juddi.model.Node;
47  import org.apache.juddi.model.Operator;
48  import org.apache.juddi.model.OperatorStatusType;
49  import org.apache.juddi.model.Publisher;
50  import org.apache.juddi.model.Reference;
51  import org.apache.juddi.model.ReplicationConfigurationNode;
52  import org.apache.juddi.model.Signature;
53  import org.apache.juddi.model.SignatureMethod;
54  import org.apache.juddi.model.SignatureTransform;
55  import org.apache.juddi.model.SignatureTransformDataValue;
56  import org.apache.juddi.model.SignatureValue;
57  import org.apache.juddi.model.SignedInfo;
58  import org.apache.juddi.model.Tmodel;
59  import org.apache.juddi.model.UddiEntity;
60  import org.apache.juddi.v3.error.ErrorMessage;
61  import org.apache.juddi.v3.error.ValueNotAllowedException;
62  import org.uddi.api_v3.Description;
63  import org.uddi.api_v3.OperationalInfo;
64  import org.uddi.api_v3.SaveBinding;
65  import org.uddi.repl_v3.ChangeRecord;
66  import org.uddi.repl_v3.CommunicationGraph;
67  import org.uddi.repl_v3.ReplicationConfiguration;
68  import org.uddi.sub_v3.ObjectFactory;
69  import org.uddi.v3_service.DispositionReportFaultMessage;
70  import org.w3._2000._09.xmldsig_.DSAKeyValueType;
71  import org.w3._2000._09.xmldsig_.KeyInfoType;
72  import org.w3._2000._09.xmldsig_.KeyValueType;
73  import org.w3._2000._09.xmldsig_.PGPDataType;
74  import org.w3._2000._09.xmldsig_.RSAKeyValueType;
75  import org.w3._2000._09.xmldsig_.ReferenceType;
76  import org.w3._2000._09.xmldsig_.RetrievalMethodType;
77  import org.w3._2000._09.xmldsig_.SPKIDataType;
78  import org.w3._2000._09.xmldsig_.TransformType;
79  import org.w3._2000._09.xmldsig_.TransformsType;
80  import org.w3._2000._09.xmldsig_.X509DataType;
81  import org.w3._2000._09.xmldsig_.X509IssuerSerialType;
82  import org.w3c.dom.DOMException;
83  import org.w3c.dom.Document;
84  import org.w3c.dom.Element;
85  import org.w3c.dom.ls.DOMImplementationLS;
86  import org.w3c.dom.ls.LSException;
87  import org.w3c.dom.ls.LSSerializer;
88  
89  /**
90   * Handles mapping from the internal jUDDL API Model to the JAXB/XML/WSDL UDDI
91   * data structures
92   *
93   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
94   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
95   * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
96   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
97   */
98  public class MappingApiToModel {
99  
100         private static Log logger = LogFactory.getLog(MappingApiToModel.class);
101 
102         /**
103          *
104          * @param apiPublisher
105          * @param modelPublisher
106          * @throws DispositionReportFaultMessage
107          */
108         public static void mapPublisher(org.apache.juddi.api_v3.Publisher apiPublisher,
109                 org.apache.juddi.model.Publisher modelPublisher)
110                 throws DispositionReportFaultMessage {
111                 modelPublisher.setAuthorizedName(apiPublisher.getAuthorizedName());
112                 modelPublisher.setPublisherName(apiPublisher.getPublisherName());
113                 modelPublisher.setEmailAddress(apiPublisher.getEmailAddress());
114                 modelPublisher.setIsAdmin(apiPublisher.isIsAdmin());
115                 modelPublisher.setIsEnabled(apiPublisher.isIsEnabled());
116                 modelPublisher.setMaxBindingsPerService(apiPublisher.getMaxBindingsPerService());
117                 modelPublisher.setMaxBusinesses(apiPublisher.getMaxBusinesses());
118                 modelPublisher.setMaxServicesPerBusiness(apiPublisher.getMaxServicePerBusiness());
119                 modelPublisher.setMaxTmodels(apiPublisher.getMaxTModels());
120                 mapPublisherSignatures(apiPublisher.getSignature(), modelPublisher);
121         }
122 
123         /**
124          *
125          * @param apiBusinessEntity
126          * @param modelBusinessEntity
127          * @throws DispositionReportFaultMessage
128          */
129         public static void mapBusinessEntity(org.uddi.api_v3.BusinessEntity apiBusinessEntity,
130                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
131                 throws DispositionReportFaultMessage {
132 
133                 modelBusinessEntity.setEntityKey(apiBusinessEntity.getBusinessKey());
134 
135                 mapBusinessNames(apiBusinessEntity.getName(), modelBusinessEntity.getBusinessNames(), modelBusinessEntity);
136                 mapBusinessDescriptions(apiBusinessEntity.getDescription(), modelBusinessEntity.getBusinessDescrs(), modelBusinessEntity);
137                 mapDiscoveryUrls(apiBusinessEntity.getDiscoveryURLs(), modelBusinessEntity.getDiscoveryUrls(), modelBusinessEntity);
138                 mapContacts(apiBusinessEntity.getContacts(), modelBusinessEntity.getContacts(), modelBusinessEntity);
139                 mapBusinessIdentifiers(apiBusinessEntity.getIdentifierBag(), modelBusinessEntity.getBusinessIdentifiers(), modelBusinessEntity);
140                 if (apiBusinessEntity.getCategoryBag() != null) {
141                         modelBusinessEntity.setCategoryBag(new org.apache.juddi.model.BusinessCategoryBag(modelBusinessEntity));
142                         mapCategoryBag(apiBusinessEntity.getCategoryBag(), modelBusinessEntity.getCategoryBag());
143                 }
144 
145                 mapBusinessServices(apiBusinessEntity.getBusinessServices(),
146                         modelBusinessEntity.getBusinessServices(),
147                         modelBusinessEntity.getServiceProjections(),
148                         modelBusinessEntity);
149 
150                 mapBusinessSignature(apiBusinessEntity.getSignature(), modelBusinessEntity);
151         }
152 
153         public static List<Signature> mapApiSignaturesToModelSignatures(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures)
154                 throws DispositionReportFaultMessage {
155                 List<Signature> modelSignatures = new ArrayList<Signature>();
156                 modelSignatures.clear();
157                 for (org.w3._2000._09.xmldsig_.SignatureType signatureType : apiSignatures) {
158                         Signature modelSignature = new Signature();
159 
160                         org.w3._2000._09.xmldsig_.SignedInfoType apiSignedInfo = signatureType.getSignedInfo();
161                         SignedInfo modelSignedInfo = new SignedInfo();
162                         modelSignature.setSignedInfo(modelSignedInfo);
163 
164                         String canonicalizationAlgMethod = apiSignedInfo.getCanonicalizationMethod().getAlgorithm();
165                         CanonicalizationMethod modelCanonMethod = new CanonicalizationMethod();
166                         modelSignedInfo.setCanonicalizationMethod(modelCanonMethod);
167                         modelCanonMethod.setAlgorithm(canonicalizationAlgMethod);
168 
169                         SignatureMethod modelSigMethod = new SignatureMethod();
170                         modelSignedInfo.setSignatureMethod(modelSigMethod);
171                         String sigMethod = apiSignedInfo.getSignatureMethod().getAlgorithm();
172                         modelSigMethod.setAlgorithm(sigMethod);
173 
174                         List<org.w3._2000._09.xmldsig_.ReferenceType> apiReferenceList = apiSignedInfo.getReference();
175                         for (org.w3._2000._09.xmldsig_.ReferenceType apiReference : apiReferenceList) {
176                                 Reference ref = mapReference(modelSignedInfo, apiReference);
177                                 modelSignedInfo.getReference().add(ref);
178                         }
179 
180                         modelSignedInfo.setCanonicalizationMethod(modelCanonMethod);
181 
182                         org.w3._2000._09.xmldsig_.SignatureValueType apiSignatureValue = signatureType.getSignatureValue();
183                         SignatureValue modelSignatureValue = new SignatureValue();
184                         byte[] signatureValueBytes = apiSignatureValue.getValue();
185                         String signatureValueXmlID = apiSignatureValue.getId();
186                         modelSignatureValue.setValue(signatureValueBytes);
187                         modelSignatureValue.setXmlID(signatureValueXmlID);
188                         modelSignature.setSignatureValue(modelSignatureValue);
189 
190                         org.w3._2000._09.xmldsig_.KeyInfoType apiKeyInfo = signatureType.getKeyInfo();
191                         String apiKeyInfoXmlID = apiKeyInfo.getId();
192                         KeyInfo modelKeyInfo = new KeyInfo();
193                         modelSignature.setKeyInfo(modelKeyInfo);
194                         modelKeyInfo.setXmlID(apiKeyInfoXmlID);
195 
196                         List<Object> apiKeyInfoContentList = apiKeyInfo.getContent();
197                         List<KeyDataValue> keyInfoDataValues = modelKeyInfo.getKeyDataValue();
198                         for (Object apiKeyInfoContentObj : apiKeyInfoContentList) {
199                                 if (apiKeyInfoContentObj instanceof JAXBElement) {
200                                         JAXBElement apiKeyInfoContentJAXB = (JAXBElement) apiKeyInfoContentObj;
201                                         String apiKeyInfoContentTagName = apiKeyInfoContentJAXB.getName().getLocalPart();
202                                         if (apiKeyInfoContentJAXB.getValue() instanceof X509DataType) {
203                                                 KeyDataValue modelX509KeyData = mapX509DataType(apiKeyInfoContentJAXB, modelKeyInfo);
204                                                 keyInfoDataValues.add(modelX509KeyData);
205                                         } else if (apiKeyInfoContentTagName.equals("KeyName")) {
206                                                 KeyDataValue modelKeyNameKDV = mapKeyName(apiKeyInfoContentJAXB);
207                                                 modelKeyNameKDV.setKeyInfo(modelKeyInfo);
208                                                 keyInfoDataValues.add(modelKeyNameKDV);
209                                         } else if (apiKeyInfoContentTagName.equals("KeyValue")) {
210                                                 KeyDataValue modelKeyValueKDV = mapKeyValue(apiKeyInfoContentJAXB, keyInfoDataValues);
211                                                 modelKeyValueKDV.setKeyInfo(modelKeyInfo);
212                                                 keyInfoDataValues.add(modelKeyValueKDV);
213                                         } else if (apiKeyInfoContentTagName.equals("MgmtData")) {
214                                                 KeyDataValue modelKeyValueKDV = new KeyDataValue();
215                                                 modelKeyValueKDV.setKeyDataName(apiKeyInfoContentTagName);
216                                                 modelKeyValueKDV.setKeyDataType("String");
217                                                 modelKeyValueKDV.setKeyDataValueString((String) apiKeyInfoContentJAXB.getValue());
218                                                 modelKeyValueKDV.setKeyInfo(modelKeyInfo);
219                                                 keyInfoDataValues.add(modelKeyValueKDV);
220                                         } else if (apiKeyInfoContentTagName.equals("RetrievalMethod")) {
221                                                 RetrievalMethodType retrievalMethodType = (RetrievalMethodType) apiKeyInfoContentJAXB.getValue();
222                                                 KeyDataValue retrievalMethodTypeKDV = mapRetrievalMethod(apiKeyInfoContentTagName, modelKeyInfo, retrievalMethodType);
223                                                 keyInfoDataValues.add(retrievalMethodTypeKDV);
224                                         } else if (apiKeyInfoContentTagName.equals("PGPData")) {
225                                                 PGPDataType pgpDataType = (PGPDataType) apiKeyInfoContentJAXB.getValue();
226                                                 KeyDataValue pgpDataTypeKDV = mapPGPDataType(apiKeyInfoContentTagName, modelKeyInfo, pgpDataType);
227                                                 keyInfoDataValues.add(pgpDataTypeKDV);
228                                         } else if (apiKeyInfoContentTagName.equals("SPKIData")) {
229                                                 SPKIDataType spkiDataType = (SPKIDataType) apiKeyInfoContentJAXB.getValue();
230                                                 KeyDataValue spkiDataTypeKDV = mapSPKIDataType(apiKeyInfoContentTagName, modelKeyInfo, spkiDataType);
231                                                 keyInfoDataValues.add(spkiDataTypeKDV);
232                                         } else {
233                                                 throw new RuntimeException("Unrecognized tag: " + apiKeyInfoContentTagName + " type: " + apiKeyInfoContentJAXB.getValue().getClass().getCanonicalName());
234                                         }
235                                 }
236                         }
237 
238                         modelSignatures.add(modelSignature);
239                 }
240                 return modelSignatures;
241         }
242 
243         /**
244          *
245          * @param apiSignatures
246          * @param modelBusinessService
247          * @throws DispositionReportFaultMessage
248          */
249         public static void mapBusinessServiceSignature(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures, BusinessService modelBusinessService)
250                 throws DispositionReportFaultMessage {
251                 List<Signature> modelSignatures = mapApiSignaturesToModelSignatures(apiSignatures);
252                 for (Signature modelSignature : modelSignatures) {
253                         modelSignature.setBusinessService(modelBusinessService);
254                 }
255                 modelBusinessService.setSignatures(modelSignatures);
256         }
257 
258         /**
259          *
260          * @param apiSignatures
261          * @param modelTmodel
262          * @throws DispositionReportFaultMessage
263          */
264         public static void mapTmodelSignatures(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures, Tmodel modelTmodel)
265                 throws DispositionReportFaultMessage {
266                 List<Signature> modelSignatures = mapApiSignaturesToModelSignatures(apiSignatures);
267                 for (Signature modelSignature : modelSignatures) {
268                         modelSignature.setTmodel(modelTmodel);
269                 }
270                 modelTmodel.setSignatures(modelSignatures);
271         }
272 
273         /**
274          *
275          * @param apiSignatures
276          * @param modelBindingTemplate
277          * @throws DispositionReportFaultMessage
278          */
279         public static void mapBindingTemplateSignatures(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures, BindingTemplate modelBindingTemplate)
280                 throws DispositionReportFaultMessage {
281                 List<Signature> modelSignatures = mapApiSignaturesToModelSignatures(apiSignatures);
282                 for (Signature modelSignature : modelSignatures) {
283                         modelSignature.setBindingTemplate(modelBindingTemplate);
284                 }
285                 modelBindingTemplate.setSignatures(modelSignatures);
286         }
287 
288         /**
289          *
290          * @param apiSignatures
291          * @param modelPublisher
292          * @throws DispositionReportFaultMessage
293          */
294         public static void mapPublisherSignatures(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures, Publisher modelPublisher)
295                 throws DispositionReportFaultMessage {
296                 List<Signature> modelSignatures = mapApiSignaturesToModelSignatures(apiSignatures);
297                 for (Signature modelSignature : modelSignatures) {
298                         modelSignature.setPublisher(modelPublisher);
299                 }
300                 modelPublisher.setSignatures(modelSignatures);
301         }
302 
303         /**
304          *
305          * @param apiSignatures
306          * @param modelBusinessEntity
307          * @throws DispositionReportFaultMessage
308          */
309         public static void mapBusinessSignature(List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures,
310                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
311                 throws DispositionReportFaultMessage {
312                 List<Signature> modelSignatures = mapApiSignaturesToModelSignatures(apiSignatures);
313                 for (Signature modelSignature : modelSignatures) {
314                         modelSignature.setBusinessEntity(modelBusinessEntity);
315                 }
316                 modelBusinessEntity.setSignatures(modelSignatures);
317         }
318 
319         /**
320          *
321          * @param apiNameList
322          * @param modelNameList
323          * @param modelBusinessEntity
324          * @throws DispositionReportFaultMessage
325          */
326         public static void mapBusinessNames(List<org.uddi.api_v3.Name> apiNameList,
327                 List<org.apache.juddi.model.BusinessName> modelNameList,
328                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
329                 throws DispositionReportFaultMessage {
330                 modelNameList.clear();
331 
332                 for (org.uddi.api_v3.Name apiName : apiNameList) {
333                         modelNameList.add(new org.apache.juddi.model.BusinessName(modelBusinessEntity, apiName.getLang(), apiName.getValue()));
334                 }
335         }
336 
337         /**
338          *
339          * @param apiDescList
340          * @param modelDescList
341          * @param modelBusinessEntity
342          * @throws DispositionReportFaultMessage
343          */
344         public static void mapBusinessDescriptions(List<org.uddi.api_v3.Description> apiDescList,
345                 List<org.apache.juddi.model.BusinessDescr> modelDescList,
346                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
347                 throws DispositionReportFaultMessage {
348                 modelDescList.clear();
349 
350                 for (org.uddi.api_v3.Description apiDesc : apiDescList) {
351                         modelDescList.add(new org.apache.juddi.model.BusinessDescr(modelBusinessEntity, apiDesc.getLang(), apiDesc.getValue()));
352                 }
353         }
354 
355         /**
356          *
357          * @param apiDiscUrls
358          * @param modelDiscUrlList
359          * @param modelBusinessEntity
360          * @throws DispositionReportFaultMessage
361          */
362         public static void mapDiscoveryUrls(org.uddi.api_v3.DiscoveryURLs apiDiscUrls,
363                 List<org.apache.juddi.model.DiscoveryUrl> modelDiscUrlList,
364                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
365                 throws DispositionReportFaultMessage {
366                 modelDiscUrlList.clear();
367 
368                 if (apiDiscUrls != null) {
369                         List<org.uddi.api_v3.DiscoveryURL> apiDiscUrlList = apiDiscUrls.getDiscoveryURL();
370                         for (org.uddi.api_v3.DiscoveryURL apiDiscUrl : apiDiscUrlList) {
371                                 modelDiscUrlList.add(new org.apache.juddi.model.DiscoveryUrl(modelBusinessEntity, apiDiscUrl.getUseType(), apiDiscUrl.getValue()));
372                         }
373                 }
374         }
375 
376         /**
377          *
378          * @param apiContacts
379          * @param modelContactList
380          * @param modelBusinessEntity
381          * @throws DispositionReportFaultMessage
382          */
383         public static void mapContacts(org.uddi.api_v3.Contacts apiContacts,
384                 List<org.apache.juddi.model.Contact> modelContactList,
385                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
386                 throws DispositionReportFaultMessage {
387                 modelContactList.clear();
388 
389                 if (apiContacts != null) {
390                         List<org.uddi.api_v3.Contact> apiContactList = apiContacts.getContact();
391                         for (org.uddi.api_v3.Contact apiContact : apiContactList) {
392                                 org.apache.juddi.model.Contact modelContact = new org.apache.juddi.model.Contact(modelBusinessEntity);
393                                 modelContact.setUseType(apiContact.getUseType());
394 
395                                 mapPersonNames(apiContact.getPersonName(), modelContact.getPersonNames(), modelContact, modelBusinessEntity.getEntityKey());
396                                 mapContactDescriptions(apiContact.getDescription(), modelContact.getContactDescrs(), modelContact, modelBusinessEntity.getEntityKey());
397                                 mapContactEmails(apiContact.getEmail(), modelContact.getEmails(), modelContact, modelBusinessEntity.getEntityKey());
398                                 mapContactPhones(apiContact.getPhone(), modelContact.getPhones(), modelContact, modelBusinessEntity.getEntityKey());
399                                 mapContactAddresses(apiContact.getAddress(), modelContact.getAddresses(), modelContact);
400 
401                                 modelContactList.add(modelContact);
402                         }
403                 }
404         }
405 
406         /**
407          *
408          * @param apiDescList
409          * @param modelDescList
410          * @param modelContact
411          * @param businessKey
412          * @throws DispositionReportFaultMessage
413          */
414         public static void mapContactDescriptions(List<org.uddi.api_v3.Description> apiDescList,
415                 List<org.apache.juddi.model.ContactDescr> modelDescList,
416                 org.apache.juddi.model.Contact modelContact,
417                 String businessKey)
418                 throws DispositionReportFaultMessage {
419                 modelDescList.clear();
420 
421                 for (org.uddi.api_v3.Description apiDesc : apiDescList) {
422                         modelDescList.add(new org.apache.juddi.model.ContactDescr(modelContact, apiDesc.getLang(), apiDesc.getValue()));
423                 }
424         }
425 
426         /**
427          *
428          * @param apiPersonNameList
429          * @param modelPersonNameList
430          * @param modelContact
431          * @param businessKey
432          * @throws DispositionReportFaultMessage
433          */
434         public static void mapPersonNames(List<org.uddi.api_v3.PersonName> apiPersonNameList,
435                 List<org.apache.juddi.model.PersonName> modelPersonNameList,
436                 org.apache.juddi.model.Contact modelContact,
437                 String businessKey)
438                 throws DispositionReportFaultMessage {
439                 modelPersonNameList.clear();
440 
441                 for (org.uddi.api_v3.PersonName apiPersonName : apiPersonNameList) {
442                         modelPersonNameList.add(new org.apache.juddi.model.PersonName(modelContact, apiPersonName.getLang(), apiPersonName.getValue()));
443                 }
444         }
445 
446         /**
447          *
448          * @param apiEmailList
449          * @param modelEmailList
450          * @param modelContact
451          * @param businessKey
452          * @throws DispositionReportFaultMessage
453          */
454         public static void mapContactEmails(List<org.uddi.api_v3.Email> apiEmailList,
455                 List<org.apache.juddi.model.Email> modelEmailList,
456                 org.apache.juddi.model.Contact modelContact,
457                 String businessKey)
458                 throws DispositionReportFaultMessage {
459                 modelEmailList.clear();
460 
461                 for (org.uddi.api_v3.Email apiEmail : apiEmailList) {
462                         modelEmailList.add(new org.apache.juddi.model.Email(modelContact, apiEmail.getUseType(), apiEmail.getValue()));
463                 }
464         }
465 
466         /**
467          *
468          * @param apiPhoneList
469          * @param modelPhoneList
470          * @param modelContact
471          * @param businessKey
472          * @throws DispositionReportFaultMessage
473          */
474         public static void mapContactPhones(List<org.uddi.api_v3.Phone> apiPhoneList,
475                 List<org.apache.juddi.model.Phone> modelPhoneList,
476                 org.apache.juddi.model.Contact modelContact,
477                 String businessKey)
478                 throws DispositionReportFaultMessage {
479                 modelPhoneList.clear();
480 
481                 for (org.uddi.api_v3.Phone apiPhone : apiPhoneList) {
482                         modelPhoneList.add(new org.apache.juddi.model.Phone(modelContact, apiPhone.getUseType(), apiPhone.getValue()));
483                 }
484         }
485 
486         /**
487          *
488          * @param apiAddressList
489          * @param modelAddressList
490          * @param modelContact
491          * @param businessKey
492          * @throws DispositionReportFaultMessage
493          */
494         public static void mapContactAddresses(List<org.uddi.api_v3.Address> apiAddressList,
495                 List<org.apache.juddi.model.Address> modelAddressList,
496                 org.apache.juddi.model.Contact modelContact
497         )
498                 throws DispositionReportFaultMessage {
499                 modelAddressList.clear();
500 
501                 for (org.uddi.api_v3.Address apiAddress : apiAddressList) {
502                         org.apache.juddi.model.Address modelAddress = new org.apache.juddi.model.Address(modelContact);
503                         modelAddress.setSortCode(apiAddress.getSortCode());
504                         modelAddress.setTmodelKey(apiAddress.getTModelKey());
505                         modelAddress.setUseType(apiAddress.getUseType());
506 
507                         mapAddressLines(apiAddress.getAddressLine(), modelAddress.getAddressLines(), modelAddress, modelContact.getId());
508 
509                         modelAddressList.add(modelAddress);
510                 }
511         }
512 
513         /**
514          *
515          * @param apiAddressLineList
516          * @param modelAddressLineList
517          * @param modelAddress
518          *
519          * @param contactId
520          * @throws DispositionReportFaultMessage
521          */
522         public static void mapAddressLines(List<org.uddi.api_v3.AddressLine> apiAddressLineList,
523                 List<org.apache.juddi.model.AddressLine> modelAddressLineList,
524                 org.apache.juddi.model.Address modelAddress,
525                 Long contactId)
526                 throws DispositionReportFaultMessage {
527                 modelAddressLineList.clear();
528 
529                 for (org.uddi.api_v3.AddressLine apiAddressLine : apiAddressLineList) {
530                         modelAddressLineList.add(new org.apache.juddi.model.AddressLine(modelAddress, apiAddressLine.getValue(), apiAddressLine.getKeyName(), apiAddressLine.getKeyValue()));
531                 }
532         }
533 
534         /**
535          *
536          * @param apiIdentifierBag
537          * @param modelIdentifierList
538          * @param modelBusinessEntity
539          * @throws DispositionReportFaultMessage
540          */
541         public static void mapBusinessIdentifiers(org.uddi.api_v3.IdentifierBag apiIdentifierBag,
542                 List<org.apache.juddi.model.BusinessIdentifier> modelIdentifierList,
543                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
544                 throws DispositionReportFaultMessage {
545                 modelIdentifierList.clear();
546 
547                 if (apiIdentifierBag != null) {
548                         List<org.uddi.api_v3.KeyedReference> apiKeyedRefList = apiIdentifierBag.getKeyedReference();
549                         for (org.uddi.api_v3.KeyedReference apiKeyedRef : apiKeyedRefList) {
550                                 modelIdentifierList.add(new org.apache.juddi.model.BusinessIdentifier(modelBusinessEntity, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
551                         }
552                 }
553         }
554 
555         /**
556          *
557          * @param apiBusinessServices
558          * @param modelBusinessServiceList
559          * @param modelServiceProjectionList
560          * @param modelBusinessEntity
561          * @throws DispositionReportFaultMessage
562          */
563         public static void mapBusinessServices(org.uddi.api_v3.BusinessServices apiBusinessServices,
564                 List<org.apache.juddi.model.BusinessService> modelBusinessServiceList,
565                 List<org.apache.juddi.model.ServiceProjection> modelServiceProjectionList,
566                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
567                 throws DispositionReportFaultMessage {
568                 modelBusinessServiceList.clear();
569                 if (apiBusinessServices != null) {
570                         List<org.uddi.api_v3.BusinessService> apiBusinessServiceList = apiBusinessServices.getBusinessService();
571                         for (org.uddi.api_v3.BusinessService apiBusinessService : apiBusinessServiceList) {
572                                 org.apache.juddi.model.BusinessService modelBusinessService = new org.apache.juddi.model.BusinessService();
573 
574                                 // If the parent businessEntity key and the service businessEntity key (if provided) do not match, it's a projection.
575                                 if (apiBusinessService.getBusinessKey() != null && apiBusinessService.getBusinessKey().length() > 0
576                                         && !modelBusinessEntity.getEntityKey().equalsIgnoreCase(apiBusinessService.getBusinessKey())) {
577 
578                                         modelBusinessService.setEntityKey(apiBusinessService.getServiceKey());
579                                         org.apache.juddi.model.ServiceProjection modelServiceProjection = new org.apache.juddi.model.ServiceProjection(modelBusinessEntity, modelBusinessService);
580 
581                                         modelServiceProjectionList.add(modelServiceProjection);
582                                 } else {
583                                         mapBusinessService(apiBusinessService, modelBusinessService, modelBusinessEntity);
584                                         modelBusinessServiceList.add(modelBusinessService);
585                                 }
586                         }
587                 }
588         }
589 
590         /**
591          *
592          * @param apiBusinessService
593          * @param modelBusinessService
594          * @param modelBusinessEntity
595          * @throws DispositionReportFaultMessage
596          */
597         public static void mapBusinessService(org.uddi.api_v3.BusinessService apiBusinessService,
598                 org.apache.juddi.model.BusinessService modelBusinessService,
599                 org.apache.juddi.model.BusinessEntity modelBusinessEntity)
600                 throws DispositionReportFaultMessage {
601 
602                 modelBusinessService.setBusinessEntity(modelBusinessEntity);
603                 modelBusinessService.setEntityKey(apiBusinessService.getServiceKey());
604 
605                 mapServiceNames(apiBusinessService.getName(), modelBusinessService.getServiceNames(), modelBusinessService);
606                 mapServiceDescriptions(apiBusinessService.getDescription(), modelBusinessService.getServiceDescrs(), modelBusinessService);
607                 if (apiBusinessService.getCategoryBag() != null) {
608                         modelBusinessService.setCategoryBag(new org.apache.juddi.model.ServiceCategoryBag(modelBusinessService));
609                         mapCategoryBag(apiBusinessService.getCategoryBag(), modelBusinessService.getCategoryBag());
610                 }
611 
612                 mapBindingTemplates(apiBusinessService.getBindingTemplates(), modelBusinessService.getBindingTemplates(), modelBusinessService);
613                 mapBusinessServiceSignature(apiBusinessService.getSignature(), modelBusinessService);
614         }
615 
616         /**
617          *
618          * @param apiNameList
619          * @param modelNameList
620          * @param modelBusinessService
621          * @throws DispositionReportFaultMessage
622          */
623         public static void mapServiceNames(List<org.uddi.api_v3.Name> apiNameList,
624                 List<org.apache.juddi.model.ServiceName> modelNameList,
625                 org.apache.juddi.model.BusinessService modelBusinessService)
626                 throws DispositionReportFaultMessage {
627                 modelNameList.clear();
628 
629                 for (org.uddi.api_v3.Name apiName : apiNameList) {
630                         modelNameList.add(new org.apache.juddi.model.ServiceName(modelBusinessService, apiName.getLang(), apiName.getValue()));
631                 }
632         }
633 
634         /**
635          *
636          * @param apiDescList
637          * @param modelDescList
638          * @param modelBusinessService
639          * @throws DispositionReportFaultMessage
640          */
641         public static void mapServiceDescriptions(List<org.uddi.api_v3.Description> apiDescList,
642                 List<org.apache.juddi.model.ServiceDescr> modelDescList,
643                 org.apache.juddi.model.BusinessService modelBusinessService)
644                 throws DispositionReportFaultMessage {
645                 modelDescList.clear();
646 
647                 for (org.uddi.api_v3.Description apiDesc : apiDescList) {
648                         modelDescList.add(new org.apache.juddi.model.ServiceDescr(modelBusinessService, apiDesc.getLang(), apiDesc.getValue()));
649                 }
650         }
651 
652         /**
653          *
654          * @param apiBindingTemplates
655          * @param modelBindingTemplateList
656          * @param modelBusinessService
657          * @throws DispositionReportFaultMessage
658          */
659         public static void mapBindingTemplates(org.uddi.api_v3.BindingTemplates apiBindingTemplates,
660                 List<org.apache.juddi.model.BindingTemplate> modelBindingTemplateList,
661                 org.apache.juddi.model.BusinessService modelBusinessService)
662                 throws DispositionReportFaultMessage {
663                 modelBindingTemplateList.clear();
664 
665                 if (apiBindingTemplates != null) {
666                         List<org.uddi.api_v3.BindingTemplate> apiBindingTemplateList = apiBindingTemplates.getBindingTemplate();
667                         for (org.uddi.api_v3.BindingTemplate apiBindingTemplate : apiBindingTemplateList) {
668                                 org.apache.juddi.model.BindingTemplate modelBindingTemplate = new org.apache.juddi.model.BindingTemplate();
669 
670                                 mapBindingTemplate(apiBindingTemplate, modelBindingTemplate, modelBusinessService);
671 
672                                 modelBindingTemplateList.add(modelBindingTemplate);
673                         }
674                 }
675         }
676 
677         /**
678          *
679          * @param apiBindingTemplate
680          * @param modelBindingTemplate
681          * @param modelBusinessService
682          * @throws DispositionReportFaultMessage
683          */
684         public static void mapBindingTemplate(org.uddi.api_v3.BindingTemplate apiBindingTemplate,
685                 org.apache.juddi.model.BindingTemplate modelBindingTemplate,
686                 org.apache.juddi.model.BusinessService modelBusinessService)
687                 throws DispositionReportFaultMessage {
688 
689                 modelBindingTemplate.setBusinessService(modelBusinessService);
690                 modelBindingTemplate.setEntityKey(apiBindingTemplate.getBindingKey());
691                 if (apiBindingTemplate.getAccessPoint() != null) {
692                         modelBindingTemplate.setAccessPointType(apiBindingTemplate.getAccessPoint().getUseType());
693                         modelBindingTemplate.setAccessPointUrl(apiBindingTemplate.getAccessPoint().getValue());
694                 }
695                 if (apiBindingTemplate.getHostingRedirector() != null) {
696                         modelBindingTemplate.setHostingRedirector(apiBindingTemplate.getHostingRedirector().getBindingKey());
697                 }
698 
699                 mapBindingDescriptions(apiBindingTemplate.getDescription(), modelBindingTemplate.getBindingDescrs(), modelBindingTemplate);
700                 if (apiBindingTemplate.getCategoryBag() != null) {
701                         modelBindingTemplate.setCategoryBag(new org.apache.juddi.model.BindingCategoryBag(modelBindingTemplate));
702                         mapCategoryBag(apiBindingTemplate.getCategoryBag(), modelBindingTemplate.getCategoryBag());
703                 }
704                 mapTModelInstanceDetails(apiBindingTemplate.getTModelInstanceDetails(), modelBindingTemplate.getTmodelInstanceInfos(), modelBindingTemplate);
705                 mapBindingTemplateSignatures(apiBindingTemplate.getSignature(), modelBindingTemplate);
706         }
707 
708         /**
709          *
710          * @param apiDescList
711          * @param modelDescList
712          * @param modelBindingTemplate
713          * @throws DispositionReportFaultMessage
714          */
715         public static void mapBindingDescriptions(List<org.uddi.api_v3.Description> apiDescList,
716                 List<org.apache.juddi.model.BindingDescr> modelDescList,
717                 org.apache.juddi.model.BindingTemplate modelBindingTemplate)
718                 throws DispositionReportFaultMessage {
719                 modelDescList.clear();
720                 for (org.uddi.api_v3.Description apiDesc : apiDescList) {
721                         modelDescList.add(new org.apache.juddi.model.BindingDescr(modelBindingTemplate, apiDesc.getLang(), apiDesc.getValue()));
722                 }
723         }
724 
725         /**
726          *
727          * @param apiCategoryBag
728          * @param modelCategoryBag
729          * @throws DispositionReportFaultMessage
730          */
731         public static void mapCategoryBag(org.uddi.api_v3.CategoryBag apiCategoryBag,
732                 org.apache.juddi.model.CategoryBag modelCategoryBag)
733                 throws DispositionReportFaultMessage {
734 
735                 if (apiCategoryBag != null) {
736                         List<org.uddi.api_v3.KeyedReference> krList = apiCategoryBag.getKeyedReference();
737                         for (Object elem : krList) {
738                                 if (elem instanceof org.uddi.api_v3.KeyedReference) {
739                                         List<org.apache.juddi.model.KeyedReference> modelKeyedReferences = modelCategoryBag.getKeyedReferences();
740                                         //modelKeyedReferences.clear();
741                                         org.uddi.api_v3.KeyedReference apiKeyedReference = (org.uddi.api_v3.KeyedReference) elem;
742                                         modelKeyedReferences.add(new org.apache.juddi.model.KeyedReference(modelCategoryBag,
743                                                 apiKeyedReference.getTModelKey(), apiKeyedReference.getKeyName(), apiKeyedReference.getKeyValue()));
744                                 }
745                         }
746                         List<org.uddi.api_v3.KeyedReferenceGroup> krgList = apiCategoryBag.getKeyedReferenceGroup();
747                         for (org.uddi.api_v3.KeyedReferenceGroup elem : krgList) {
748                                 if (elem instanceof org.uddi.api_v3.KeyedReferenceGroup) {
749                                         org.uddi.api_v3.KeyedReferenceGroup apiKeyedReferenceGroup = (org.uddi.api_v3.KeyedReferenceGroup) elem;
750 
751                                         org.apache.juddi.model.KeyedReferenceGroup modelKeyedReferenceGroup = new org.apache.juddi.model.KeyedReferenceGroup();
752                                         List<org.apache.juddi.model.KeyedReferenceGroup> modelKeyedReferenceGroups = modelCategoryBag.getKeyedReferenceGroups();
753                                         //modelKeyedReferenceGroups.clear();
754 
755                                         mapKeyedReferenceGroup(apiKeyedReferenceGroup, modelKeyedReferenceGroup, modelCategoryBag);
756 
757                                         modelKeyedReferenceGroups.add(modelKeyedReferenceGroup);
758                                 }
759                         }
760                 }
761         }
762 
763         /**
764          *
765          * @param apiKeyedReferenceGroup
766          * @param modelKeyedReferenceGroup
767          * @param modelCategoryBag
768          * @throws DispositionReportFaultMessage
769          */
770         public static void mapKeyedReferenceGroup(org.uddi.api_v3.KeyedReferenceGroup apiKeyedReferenceGroup,
771                 org.apache.juddi.model.KeyedReferenceGroup modelKeyedReferenceGroup,
772                 org.apache.juddi.model.CategoryBag modelCategoryBag)
773                 throws DispositionReportFaultMessage {
774                 if (apiKeyedReferenceGroup != null) {
775                         modelKeyedReferenceGroup.setCategoryBag(modelCategoryBag);
776                         modelKeyedReferenceGroup.setTmodelKey(apiKeyedReferenceGroup.getTModelKey());
777 
778                         if (apiKeyedReferenceGroup.getKeyedReference() != null) {
779                                 List<org.apache.juddi.model.KeyedReference> modelKeyedReferences = modelKeyedReferenceGroup.getKeyedReferences();
780                                 for (org.uddi.api_v3.KeyedReference apiKeyedReference : apiKeyedReferenceGroup.getKeyedReference()) {
781                                         modelKeyedReferences.add(new org.apache.juddi.model.KeyedReference(modelKeyedReferenceGroup,
782                                                 apiKeyedReference.getTModelKey(), apiKeyedReference.getKeyName(), apiKeyedReference.getKeyValue()));
783                                 }
784                         }
785 
786                 }
787 
788         }
789 
790         /**
791          *
792          * @param apiTModelInstDetails
793          * @param modelTModelInstInfoList
794          * @param modelBindingTemplate
795          * @throws DispositionReportFaultMessage
796          */
797         public static void mapTModelInstanceDetails(org.uddi.api_v3.TModelInstanceDetails apiTModelInstDetails,
798                 List<org.apache.juddi.model.TmodelInstanceInfo> modelTModelInstInfoList,
799                 org.apache.juddi.model.BindingTemplate modelBindingTemplate)
800                 throws DispositionReportFaultMessage {
801                 modelTModelInstInfoList.clear();
802 
803                 if (apiTModelInstDetails != null) {
804                         List<org.uddi.api_v3.TModelInstanceInfo> apiTModelInstInfoList = apiTModelInstDetails.getTModelInstanceInfo();
805                         for (org.uddi.api_v3.TModelInstanceInfo apiTModelInstInfo : apiTModelInstInfoList) {
806                                 org.apache.juddi.model.TmodelInstanceInfo modelTModelInstInfo = new org.apache.juddi.model.TmodelInstanceInfo(modelBindingTemplate, apiTModelInstInfo.getTModelKey());
807 
808                                 mapTModelInstanceInfoDescriptions(apiTModelInstInfo.getDescription(), modelTModelInstInfo.getTmodelInstanceInfoDescrs(), modelTModelInstInfo);
809                                 mapInstanceDetails(apiTModelInstInfo.getInstanceDetails(), modelTModelInstInfo);
810 
811                                 modelTModelInstInfoList.add(modelTModelInstInfo);
812                         }
813                 }
814         }
815 
816         /**
817          *
818          * @param apiDescList
819          * @param modelDescList
820          * @param modelTModelInstInfo
821          * @throws DispositionReportFaultMessage
822          */
823         public static void mapTModelInstanceInfoDescriptions(List<org.uddi.api_v3.Description> apiDescList,
824                 List<org.apache.juddi.model.TmodelInstanceInfoDescr> modelDescList,
825                 org.apache.juddi.model.TmodelInstanceInfo modelTModelInstInfo)
826                 throws DispositionReportFaultMessage {
827                 modelDescList.clear();
828 
829                 for (org.uddi.api_v3.Description apiDesc : apiDescList) {
830                         modelDescList.add(new org.apache.juddi.model.TmodelInstanceInfoDescr(modelTModelInstInfo, apiDesc.getLang(), apiDesc.getValue()));
831                 }
832         }
833 
834         /**
835          *
836          * @param apiInstanceDetails
837          * @param modelTmodelInstInfo
838          * @throws DispositionReportFaultMessage
839          */
840         public static void mapInstanceDetails(org.uddi.api_v3.InstanceDetails apiInstanceDetails,
841                 org.apache.juddi.model.TmodelInstanceInfo modelTmodelInstInfo)
842                 throws DispositionReportFaultMessage {
843                 modelTmodelInstInfo.getInstanceDetailsDescrs().clear();
844 
845                 if (apiInstanceDetails != null) {
846                         List<org.uddi.api_v3.Description> descriptions = apiInstanceDetails.getDescription();
847                         List<org.uddi.api_v3.OverviewDoc> overviewdocs = apiInstanceDetails.getOverviewDoc();
848                         for (org.uddi.api_v3.Description apiDesc : descriptions) {
849                                 org.apache.juddi.model.InstanceDetailsDescr modelInstanceDetailsDescr
850                                         = new org.apache.juddi.model.InstanceDetailsDescr(
851                                                 modelTmodelInstInfo, apiDesc.getLang(), apiDesc.getValue());
852                                 modelTmodelInstInfo.getInstanceDetailsDescrs().add(modelInstanceDetailsDescr);
853                         }
854                         for (org.uddi.api_v3.OverviewDoc apiOverviewDoc : overviewdocs) {
855                                 org.apache.juddi.model.OverviewDoc modelOverviewDoc = new org.apache.juddi.model.OverviewDoc(modelTmodelInstInfo);
856                                 mapOverviewDoc(apiOverviewDoc, modelOverviewDoc);
857                                 modelTmodelInstInfo.getOverviewDocs().add(modelOverviewDoc);
858                         }
859                         modelTmodelInstInfo.setInstanceParms((String) apiInstanceDetails.getInstanceParms());
860                 }
861         }
862 
863         /**
864          *
865          * @param apiOverviewDoc
866          * @param modelOverviewDoc
867          * @throws DispositionReportFaultMessage
868          */
869         public static void mapOverviewDoc(org.uddi.api_v3.OverviewDoc apiOverviewDoc,
870                 org.apache.juddi.model.OverviewDoc modelOverviewDoc)
871                 throws DispositionReportFaultMessage {
872                 if (apiOverviewDoc != null) {
873 
874                         List<Description> descContent = apiOverviewDoc.getDescription();
875                         for (Object elem : descContent) {
876                                 org.uddi.api_v3.Description description = (org.uddi.api_v3.Description) elem;
877                                 if (description != null) {
878                                         org.apache.juddi.model.OverviewDocDescr modelOverviewDocDescr = new org.apache.juddi.model.OverviewDocDescr(
879                                                 modelOverviewDoc, description.getLang(), description.getValue());
880                                         modelOverviewDoc.getOverviewDocDescrs().add(modelOverviewDocDescr);
881                                 }
882                         }
883 
884                         org.uddi.api_v3.OverviewURL elem = apiOverviewDoc.getOverviewURL();
885                         if (elem instanceof org.uddi.api_v3.OverviewURL) {
886                                 org.uddi.api_v3.OverviewURL overviewURL = elem;
887                                 modelOverviewDoc.setOverviewUrl(overviewURL.getValue());
888                                 modelOverviewDoc.setOverviewUrlUseType(overviewURL.getUseType());
889                         }
890 
891                 }
892         }
893 
894         /**
895          *
896          * @param apiTModel
897          * @param modelTModel
898          * @throws DispositionReportFaultMessage
899          */
900         public static void mapTModel(org.uddi.api_v3.TModel apiTModel,
901                 org.apache.juddi.model.Tmodel modelTModel)
902                 throws DispositionReportFaultMessage {
903 
904                 modelTModel.setEntityKey(apiTModel.getTModelKey());
905                 modelTModel.setName(apiTModel.getName().getValue());
906                 modelTModel.setLangCode(apiTModel.getName().getLang());
907                 modelTModel.setDeleted(apiTModel.isDeleted());
908 
909                 mapTModelDescriptions(apiTModel.getDescription(), modelTModel.getTmodelDescrs(), modelTModel);
910                 mapTModelIdentifiers(apiTModel.getIdentifierBag(), modelTModel.getTmodelIdentifiers(), modelTModel);
911                 if (apiTModel.getCategoryBag() != null) {
912                         modelTModel.setCategoryBag(new org.apache.juddi.model.TmodelCategoryBag(modelTModel));
913                         mapCategoryBag(apiTModel.getCategoryBag(), modelTModel.getCategoryBag());
914                 }
915                 mapTModelOverviewDocs(apiTModel.getOverviewDoc(), modelTModel.getOverviewDocs(), modelTModel);
916                 mapTmodelSignatures(apiTModel.getSignature(), modelTModel);
917         }
918 
919         /**
920          *
921          * @param apiDescList
922          * @param modelDescList
923          * @param modelTModel
924          * @throws DispositionReportFaultMessage
925          */
926         public static void mapTModelDescriptions(List<org.uddi.api_v3.Description> apiDescList,
927                 List<org.apache.juddi.model.TmodelDescr> modelDescList,
928                 org.apache.juddi.model.Tmodel modelTModel)
929                 throws DispositionReportFaultMessage {
930                 modelDescList.clear();
931 
932                 for (org.uddi.api_v3.Description apiDesc : apiDescList) {
933                         modelDescList.add(new org.apache.juddi.model.TmodelDescr(modelTModel, apiDesc.getLang(), apiDesc.getValue()));
934                 }
935         }
936 
937         /**
938          *
939          * @param apiIdentifierBag
940          * @param modelIdentifierList
941          * @param modelTModel
942          * @throws DispositionReportFaultMessage
943          */
944         public static void mapTModelIdentifiers(org.uddi.api_v3.IdentifierBag apiIdentifierBag,
945                 List<org.apache.juddi.model.TmodelIdentifier> modelIdentifierList,
946                 org.apache.juddi.model.Tmodel modelTModel)
947                 throws DispositionReportFaultMessage {
948                 modelIdentifierList.clear();
949 
950                 if (apiIdentifierBag != null) {
951                         List<org.uddi.api_v3.KeyedReference> apiKeyedRefList = apiIdentifierBag.getKeyedReference();
952                         for (org.uddi.api_v3.KeyedReference apiKeyedRef : apiKeyedRefList) {
953                                 modelIdentifierList.add(new org.apache.juddi.model.TmodelIdentifier(modelTModel, apiKeyedRef.getTModelKey(), apiKeyedRef.getKeyName(), apiKeyedRef.getKeyValue()));
954                         }
955                 }
956         }
957 
958         /**
959          *
960          * @param apiOverviewDocList
961          * @param modelOverviewDocList
962          * @param modelTmodel
963          * @throws DispositionReportFaultMessage
964          */
965         public static void mapTModelOverviewDocs(List<org.uddi.api_v3.OverviewDoc> apiOverviewDocList,
966                 List<org.apache.juddi.model.OverviewDoc> modelOverviewDocList,
967                 org.apache.juddi.model.Tmodel modelTmodel)
968                 throws DispositionReportFaultMessage {
969                 modelOverviewDocList.clear();
970 
971                 for (org.uddi.api_v3.OverviewDoc apiOverviewDoc : apiOverviewDocList) {
972                         org.apache.juddi.model.OverviewDoc modelOverviewDoc = new org.apache.juddi.model.OverviewDoc(modelTmodel);
973                         mapOverviewDoc(apiOverviewDoc, modelOverviewDoc);
974                         modelTmodel.getOverviewDocs().add(modelOverviewDoc);
975                 }
976         }
977 
978         /**
979          * note that when using this, it does not reference the instance of the
980          * specific businesses, it will create new ones. be sure to overwrite
981          * them with the correct references
982          *
983          * @param apiPubAssertion
984          * @param modelPubAssertion
985          * @throws DispositionReportFaultMessage
986          */
987         public static void mapPublisherAssertion(org.uddi.api_v3.PublisherAssertion apiPubAssertion,
988                 org.apache.juddi.model.PublisherAssertion modelPubAssertion)
989                 throws DispositionReportFaultMessage {
990 
991                 modelPubAssertion.setId(new org.apache.juddi.model.PublisherAssertionId(apiPubAssertion.getFromKey(), apiPubAssertion.getToKey()));
992 
993                 org.apache.juddi.model.BusinessEntity beFrom = new org.apache.juddi.model.BusinessEntity();
994                 beFrom.setEntityKey(apiPubAssertion.getFromKey());
995                 modelPubAssertion.setBusinessEntityByFromKey(beFrom);
996 
997                 org.apache.juddi.model.BusinessEntity beTo = new org.apache.juddi.model.BusinessEntity();
998                 beFrom.setEntityKey(apiPubAssertion.getToKey());
999                 modelPubAssertion.setBusinessEntityByToKey(beTo);
1000 
1001                 org.uddi.api_v3.KeyedReference apiKeyedRef = apiPubAssertion.getKeyedReference();
1002                 if (apiKeyedRef != null) {
1003                         modelPubAssertion.setTmodelKey(apiKeyedRef.getTModelKey());
1004                         modelPubAssertion.setKeyName(apiKeyedRef.getKeyName());
1005                         modelPubAssertion.setKeyValue(apiKeyedRef.getKeyValue());
1006                 }
1007                 if (!apiPubAssertion.getSignature().isEmpty()) {
1008                         modelPubAssertion.setSignatures(mapApiSignaturesToModelSignatures(apiPubAssertion.getSignature()));
1009                         for (Signature s : modelPubAssertion.getSignatures()) {
1010                                 s.setPublisherAssertionFromKey(modelPubAssertion.getBusinessEntityByFromKey().getEntityKey());
1011                                 s.setPublisherAssertionToKey(modelPubAssertion.getBusinessEntityByToKey().getEntityKey());
1012 
1013                         }
1014 
1015                 }
1016         }
1017 
1018         /**
1019          *
1020          * @param apiSubscription
1021          * @param modelSubscription
1022          * @throws DispositionReportFaultMessage
1023          */
1024         public static void mapSubscription(org.uddi.sub_v3.Subscription apiSubscription,
1025                 org.apache.juddi.model.Subscription modelSubscription)
1026                 throws DispositionReportFaultMessage {
1027 
1028                 modelSubscription.setSubscriptionKey(apiSubscription.getSubscriptionKey());
1029                 modelSubscription.setBindingKey(apiSubscription.getBindingKey());
1030                 if (apiSubscription.getNotificationInterval() != null) {
1031                         modelSubscription.setNotificationInterval(apiSubscription.getNotificationInterval().toString());
1032                 }
1033                 modelSubscription.setMaxEntities(apiSubscription.getMaxEntities());
1034                 if (apiSubscription.getExpiresAfter() != null) {
1035                         GregorianCalendar gc = apiSubscription.getExpiresAfter().toGregorianCalendar();
1036                         modelSubscription.setExpiresAfter(new Date(gc.getTimeInMillis()));
1037                 }
1038 
1039                 if (apiSubscription.isBrief() != null) {
1040                         modelSubscription.setBrief(apiSubscription.isBrief());
1041                 } else {
1042                         modelSubscription.setBrief(Boolean.FALSE);
1043                 }
1044 
1045                 String rawFilter = JAXBMarshaller.marshallToString(new ObjectFactory().createSubscriptionFilter(apiSubscription.getSubscriptionFilter()), "org.uddi.sub_v3");
1046                 logger.debug("marshalled subscription filter:  " + rawFilter);
1047                 modelSubscription.setSubscriptionFilter(rawFilter);
1048 
1049         }
1050 
1051         /**
1052          *
1053          * @param apiClientSubscriptionInfo
1054          * @param modelClientSubscriptionInfo
1055          * @throws DispositionReportFaultMessage
1056          */
1057         public static void mapClientSubscriptionInfo(org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo,
1058                 org.apache.juddi.model.ClientSubscriptionInfo modelClientSubscriptionInfo)
1059                 throws DispositionReportFaultMessage {
1060 
1061                 modelClientSubscriptionInfo.setLastNotified(new Date());
1062                 modelClientSubscriptionInfo.setSubscriptionKey(apiClientSubscriptionInfo.getSubscriptionKey());
1063                 if (apiClientSubscriptionInfo.getFromClerk() != null) {
1064                         org.apache.juddi.model.Clerk modelClerk = new org.apache.juddi.model.Clerk();
1065                         mapClerk(apiClientSubscriptionInfo.getFromClerk(), modelClerk);
1066                         modelClientSubscriptionInfo.setFromClerk(modelClerk);
1067                 }
1068                 if (apiClientSubscriptionInfo.getToClerk() != null) {
1069                         org.apache.juddi.model.Clerk modelToClerk = new org.apache.juddi.model.Clerk();
1070                         mapClerk(apiClientSubscriptionInfo.getToClerk(), modelToClerk);
1071                         modelClientSubscriptionInfo.setToClerk(modelToClerk);
1072                 }
1073 
1074         }
1075 
1076         /**
1077          *
1078          * @param apiClerk
1079          * @param modelClerk
1080          */
1081         public static void mapClerk(org.apache.juddi.api_v3.Clerk apiClerk, org.apache.juddi.model.Clerk modelClerk) {
1082                 if (apiClerk != null) {
1083 
1084                         modelClerk.setClerkName(apiClerk.getName());
1085                         modelClerk.setCred(apiClerk.getPassword());
1086                         modelClerk.setPublisherId(apiClerk.getPublisher());
1087                         if (apiClerk.getNode() != null) {
1088                                 org.apache.juddi.model.Node modelNode = new org.apache.juddi.model.Node();
1089                                 mapNode(apiClerk.getNode(), modelNode);
1090                                 modelClerk.setNode(modelNode.getName());
1091                         }
1092                 }
1093         }
1094 
1095         /**
1096          *
1097          * @param apiNode
1098          * @param modelNode
1099          */
1100         public static void mapNode(org.apache.juddi.api_v3.Node apiNode, org.apache.juddi.model.Node modelNode) {
1101                 if (apiNode != null) {
1102 
1103                         modelNode.setCustodyTransferUrl(apiNode.getCustodyTransferUrl());
1104                         modelNode.setInquiryUrl(apiNode.getInquiryUrl());
1105                         modelNode.setJuddiApiUrl(apiNode.getJuddiApiUrl());
1106                         modelNode.setName(apiNode.getName());
1107                         modelNode.setClientName(apiNode.getClientName());
1108                         modelNode.setProxyTransport(apiNode.getProxyTransport());
1109                         modelNode.setPublishUrl(apiNode.getPublishUrl());
1110                         modelNode.setSecurityUrl(apiNode.getSecurityUrl());
1111                         modelNode.setSubscriptionUrl(apiNode.getSubscriptionUrl());
1112                         modelNode.setSubscriptionListenerUrl(apiNode.getSubscriptionListenerUrl());
1113                         modelNode.setReplicationUrl(apiNode.getReplicationUrl());
1114                         modelNode.setFactoryInitial(apiNode.getFactoryInitial());
1115                         modelNode.setFactoryNamingProvider(apiNode.getFactoryNamingProvider());
1116                         modelNode.setFactoryURLPkgs(apiNode.getFactoryURLPkgs());
1117                 }
1118         }
1119 
1120         private static Reference mapReference(SignedInfo modelSignedInfo, ReferenceType apiReference) {
1121                 Reference ref = new Reference();
1122                 ref.setSignedInfo(modelSignedInfo);
1123                 String refUri = apiReference.getURI();
1124                 if (refUri == null) {
1125                         refUri = "";
1126                 }
1127                 ref.setUri(refUri);
1128                 List<org.w3._2000._09.xmldsig_.TransformType> apiTransformList = apiReference.getTransforms().getTransform();
1129                 for (org.w3._2000._09.xmldsig_.TransformType apiTransform : apiTransformList) {
1130                         SignatureTransform modelTransform = new SignatureTransform();
1131                         modelTransform.setReference(ref);
1132                         modelTransform.setTransform(apiTransform.getAlgorithm());
1133 
1134                         for (Object xform : apiTransform.getContent()) {
1135                                 SignatureTransformDataValue sdv = mapSignatureTransformDataValue(xform);
1136                                 sdv.setSignatureTransform(modelTransform);
1137                                 modelTransform.getSignatureTransformDataValue().add(sdv);
1138                         }
1139 
1140                         ref.getTransforms().add(modelTransform);
1141                 }
1142                 String digestMethodStr = apiReference.getDigestMethod().getAlgorithm();
1143                 byte[] digestValueBytes = apiReference.getDigestValue();
1144                 ref.setDigestMethod(digestMethodStr);
1145                 ref.setDigestValue(digestValueBytes);
1146                 return ref;
1147         }
1148 
1149         private static KeyDataValue mapX509DataType(JAXBElement apiKeyInfoContentJAXB, KeyInfo modelKeyInfo) throws RuntimeException {
1150                 X509DataType apiKeyInfoContent = (X509DataType) apiKeyInfoContentJAXB.getValue();
1151                 KeyDataValue modelX509KeyData = new KeyDataValue();
1152                 modelX509KeyData.setKeyDataType(X509DataType.class.getSimpleName());
1153                 modelX509KeyData.setKeyDataName(apiKeyInfoContentJAXB.getName().getLocalPart());
1154                 modelX509KeyData.setKeyInfo(modelKeyInfo);
1155                 List<Object> x509IssuerSerialOrX509SKIOrX509SubjectNameList = apiKeyInfoContent.getX509IssuerSerialOrX509SKIOrX509SubjectName();
1156                 for (Object x509IssuerSerialOrX509SKIOrX509SubjectNameObj : x509IssuerSerialOrX509SKIOrX509SubjectNameList) {
1157                         JAXBElement x509IssuerSerialOrX509SKIOrX509SubjectNameJAXB = (JAXBElement) x509IssuerSerialOrX509SKIOrX509SubjectNameObj;
1158                         String tagName = x509IssuerSerialOrX509SKIOrX509SubjectNameJAXB.getName().getLocalPart();
1159                         Object x509IssuerSerialOrX509SKIOrX509SubjectName = x509IssuerSerialOrX509SKIOrX509SubjectNameJAXB.getValue();
1160 
1161                         KeyDataValue modelKeyInfoValue = new KeyDataValue();
1162                         modelKeyInfoValue.setKeyDataName(tagName);
1163                         if (x509IssuerSerialOrX509SKIOrX509SubjectName instanceof byte[]) {
1164                                 modelKeyInfoValue.setKeyDataValueBytes((byte[]) x509IssuerSerialOrX509SKIOrX509SubjectName);
1165                         } else if (x509IssuerSerialOrX509SKIOrX509SubjectName instanceof String) {
1166                                 modelKeyInfoValue.setKeyDataValueString((String) x509IssuerSerialOrX509SKIOrX509SubjectName);
1167                         } else if (x509IssuerSerialOrX509SKIOrX509SubjectName instanceof X509IssuerSerialType) {
1168                                 modelKeyInfoValue.setKeyDataType(X509IssuerSerialType.class.getSimpleName());
1169                                 X509IssuerSerialType x509IssuerSerialType = (X509IssuerSerialType) x509IssuerSerialOrX509SKIOrX509SubjectName;
1170                                 modelKeyInfoValue.setKeyDataValueString(x509IssuerSerialType.getX509IssuerName());
1171                                 modelKeyInfoValue.setKeyDataValueBytes(x509IssuerSerialType.getX509SerialNumber().toByteArray());
1172                         } else if (x509IssuerSerialOrX509SKIOrX509SubjectName != null) {
1173                                 throw new RuntimeException("Unrecognized Value for Element: " + tagName + ": " + x509IssuerSerialOrX509SKIOrX509SubjectName.getClass().getCanonicalName());
1174                         }
1175                         modelKeyInfoValue.setKeyDataValue(modelX509KeyData);
1176                         modelX509KeyData.getKeyDataValueList().add(modelKeyInfoValue);
1177                 }
1178                 return modelX509KeyData;
1179         }
1180 
1181         private static KeyDataValue mapKeyName(JAXBElement apiKeyInfoContentJAXB) {
1182                 KeyDataValue modelKeyNameKDV = new KeyDataValue();
1183                 modelKeyNameKDV.setKeyDataType(String.class.getSimpleName());
1184                 modelKeyNameKDV.setKeyDataName(apiKeyInfoContentJAXB.getName().getLocalPart());
1185                 modelKeyNameKDV.setKeyDataValueString((String) apiKeyInfoContentJAXB.getValue());
1186                 return modelKeyNameKDV;
1187         }
1188 
1189         private static KeyDataValue mapKeyValue(JAXBElement apiKeyInfoContentJAXB, List<KeyDataValue> keyInfoDataValues) {
1190                 KeyValueType kvt = (KeyValueType) apiKeyInfoContentJAXB.getValue();
1191                 KeyDataValue modelKeyValueKDV = new KeyDataValue();
1192                 modelKeyValueKDV.setKeyDataType(KeyValueType.class.getSimpleName());
1193                 modelKeyValueKDV.setKeyDataName(apiKeyInfoContentJAXB.getName().getLocalPart());
1194                 keyInfoDataValues.add(modelKeyValueKDV);
1195                 List<Object> kvObjList = kvt.getContent();
1196                 for (Object kvObj : kvObjList) {
1197                         if (kvObj instanceof JAXBElement) {
1198                                 JAXBElement kvJAXB = (JAXBElement) kvObj;
1199                                 Object childVal = kvJAXB.getValue();
1200 
1201                                 KeyDataValue childKDV = new KeyDataValue();
1202                                 childKDV.setKeyDataValue(modelKeyValueKDV);
1203                                 childKDV.setKeyDataName(kvJAXB.getName().getLocalPart());
1204                                 childKDV.setKeyDataType(childVal.getClass().getSimpleName());
1205                                 modelKeyValueKDV.getKeyDataValueList().add(childKDV);
1206 
1207                                 if (childVal instanceof DSAKeyValueType) {
1208                                         DSAKeyValueType dsaKeyVal = (DSAKeyValueType) childVal;
1209                                         String dsaKeyValueTagName = kvJAXB.getName().getLocalPart();
1210                                         KeyDataValue dsaKeyValKDV = new KeyDataValue(null, DSAKeyValueType.class.getSimpleName(), dsaKeyValueTagName, null, null, childKDV);
1211                                         childKDV.getKeyDataValueList().add(dsaKeyValKDV);
1212 
1213                                         KeyDataValue gValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "G", dsaKeyVal.getG(), null, dsaKeyValKDV);
1214                                         dsaKeyValKDV.getKeyDataValueList().add(gValKDV);
1215 
1216                                         KeyDataValue jValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "J", dsaKeyVal.getJ(), null, dsaKeyValKDV);
1217                                         dsaKeyValKDV.getKeyDataValueList().add(jValKDV);
1218 
1219                                         KeyDataValue pValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "P", dsaKeyVal.getP(), null, dsaKeyValKDV);
1220                                         dsaKeyValKDV.getKeyDataValueList().add(pValKDV);
1221 
1222                                         KeyDataValue pGenCounterValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "PgenCounter", dsaKeyVal.getPgenCounter(), null, dsaKeyValKDV);
1223                                         dsaKeyValKDV.getKeyDataValueList().add(pGenCounterValKDV);
1224 
1225                                         KeyDataValue qValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Q", dsaKeyVal.getQ(), null, dsaKeyValKDV);
1226                                         dsaKeyValKDV.getKeyDataValueList().add(qValKDV);
1227 
1228                                         KeyDataValue seedValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Seed", dsaKeyVal.getSeed(), null, dsaKeyValKDV);
1229                                         dsaKeyValKDV.getKeyDataValueList().add(seedValKDV);
1230 
1231                                         KeyDataValue yValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Y", dsaKeyVal.getY(), null, dsaKeyValKDV);
1232                                         dsaKeyValKDV.getKeyDataValueList().add(yValKDV);
1233                                 } else if (childVal instanceof RSAKeyValueType) {
1234                                         RSAKeyValueType rsaKeyVal = (RSAKeyValueType) childVal;
1235                                         String rsaKeyValueTagName = kvJAXB.getName().getLocalPart();
1236                                         KeyDataValue rsaKeyValKDV = new KeyDataValue(null, RSAKeyValueType.class.getSimpleName(), rsaKeyValueTagName, null, null, childKDV);
1237                                         childKDV.getKeyDataValueList().add(rsaKeyValKDV);
1238 
1239                                         KeyDataValue exponentValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Exponent", rsaKeyVal.getExponent(), null, rsaKeyValKDV);
1240                                         rsaKeyValKDV.getKeyDataValueList().add(exponentValKDV);
1241 
1242                                         KeyDataValue modulusValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Modulus", rsaKeyVal.getModulus(), null, rsaKeyValKDV);
1243                                         rsaKeyValKDV.getKeyDataValueList().add(modulusValKDV);
1244                                 }
1245                         }
1246                 }
1247                 return modelKeyValueKDV;
1248         }
1249 
1250         private static KeyDataValue mapRetrievalMethod(String apiKeyInfoContentTagName, KeyInfo modelKeyInfo, RetrievalMethodType retrievalMethodType) {
1251                 KeyDataValue retrievalMethodTypeKDV = new KeyDataValue();
1252                 retrievalMethodTypeKDV.setKeyDataName(apiKeyInfoContentTagName);
1253                 retrievalMethodTypeKDV.setKeyDataType(RetrievalMethodType.class.getSimpleName());
1254                 retrievalMethodTypeKDV.setKeyInfo(modelKeyInfo);
1255                 KeyDataValue uriKDV = new KeyDataValue();
1256                 uriKDV.setKeyDataName("URI");
1257                 uriKDV.setKeyDataType(String.class.getSimpleName());
1258                 uriKDV.setKeyDataValue(retrievalMethodTypeKDV);
1259                 uriKDV.setKeyDataValueString(retrievalMethodType.getURI());
1260                 retrievalMethodTypeKDV.getKeyDataValueList().add(uriKDV);
1261                 KeyDataValue typeKDV = new KeyDataValue();
1262                 typeKDV.setKeyDataName("Type");
1263                 typeKDV.setKeyDataType(String.class.getSimpleName());
1264                 typeKDV.setKeyDataValue(retrievalMethodTypeKDV);
1265                 typeKDV.setKeyDataValueString(retrievalMethodType.getType());
1266                 retrievalMethodTypeKDV.getKeyDataValueList().add(typeKDV);
1267                 TransformsType transformsType = retrievalMethodType.getTransforms();
1268                 if (transformsType != null) {
1269                         List<TransformType> tTypeList = transformsType.getTransform();
1270                         for (TransformType tType : tTypeList) {
1271                                 KeyDataValue transformKDV = new KeyDataValue();
1272                                 transformKDV.setKeyDataName("Transform");
1273                                 transformKDV.setKeyDataType(String.class.getSimpleName());
1274                                 transformKDV.setKeyDataValue(retrievalMethodTypeKDV);
1275                                 transformKDV.setKeyDataValueString(tType.getAlgorithm());
1276 
1277                                 for (Object xform : tType.getContent()) {
1278                                         SignatureTransformDataValue stdv = mapSignatureTransformDataValue(xform);
1279                                         KeyDataValue transformContentKDV = new KeyDataValue();
1280                                         transformContentKDV.setKeyDataType(stdv.getContentType());
1281                                         transformContentKDV.setKeyDataValueBytes(stdv.getContentBytes());
1282                                         transformContentKDV.setKeyDataValue(transformKDV);
1283                                         transformKDV.getKeyDataValueList().add(transformContentKDV);
1284                                 }
1285 
1286                                 retrievalMethodTypeKDV.getKeyDataValueList().add(transformKDV);
1287                         }
1288                 }
1289                 return retrievalMethodTypeKDV;
1290         }
1291 
1292         private static KeyDataValue mapPGPDataType(String apiKeyInfoContentTagName, KeyInfo modelKeyInfo, PGPDataType pgpDataType) {
1293                 KeyDataValue pgpDataTypeKDV = new KeyDataValue();
1294                 pgpDataTypeKDV.setKeyDataName(apiKeyInfoContentTagName);
1295                 pgpDataTypeKDV.setKeyDataType(PGPDataType.class.getSimpleName());
1296                 pgpDataTypeKDV.setKeyInfo(modelKeyInfo);
1297 
1298                 List<Object> pgpDataValues = pgpDataType.getContent();
1299                 for (Object pgpDataValue : pgpDataValues) {
1300                         if (pgpDataValue instanceof JAXBElement) {
1301                                 JAXBElement pgpDataJAXB = (JAXBElement) pgpDataValue;
1302                                 String tagName = pgpDataJAXB.getName().getLocalPart();
1303 
1304                                 KeyDataValue keyIDKDV = new KeyDataValue();
1305                                 keyIDKDV.setKeyDataName(tagName);
1306                                 keyIDKDV.setKeyDataValue(pgpDataTypeKDV);
1307                                 if (pgpDataJAXB.getValue() instanceof String) {
1308                                         keyIDKDV.setKeyDataValueString((String) pgpDataJAXB.getValue());
1309                                 } else {
1310                                         keyIDKDV.setKeyDataValueBytes((byte[]) pgpDataJAXB.getValue());
1311                                 }
1312                                 pgpDataTypeKDV.getKeyDataValueList().add(keyIDKDV);
1313                         }
1314                 }
1315                 return pgpDataTypeKDV;
1316         }
1317 
1318         private static KeyDataValue mapSPKIDataType(String apiKeyInfoContentTagName, KeyInfo modelKeyInfo, SPKIDataType spkiDataType) {
1319                 KeyDataValue spkiDataTypeKDV = new KeyDataValue();
1320                 spkiDataTypeKDV.setKeyDataName(apiKeyInfoContentTagName);
1321                 spkiDataTypeKDV.setKeyDataType(SPKIDataType.class.getSimpleName());
1322                 spkiDataTypeKDV.setKeyInfo(modelKeyInfo);
1323 
1324                 List<Object> spkiDataValues = spkiDataType.getSPKISexpAndAny();
1325                 for (Object spkiDataValue : spkiDataValues) {
1326                         if (spkiDataValue instanceof JAXBElement) {
1327                                 JAXBElement spkiDataJAXB = (JAXBElement) spkiDataValue;
1328                                 String tagName = spkiDataJAXB.getName().getLocalPart();
1329 
1330                                 KeyDataValue keyIDKDV = new KeyDataValue();
1331                                 keyIDKDV.setKeyDataName(tagName);
1332                                 keyIDKDV.setKeyDataValue(spkiDataTypeKDV);
1333                                 if (spkiDataJAXB.getValue() instanceof String) {
1334                                         keyIDKDV.setKeyDataValueString((String) spkiDataJAXB.getValue());
1335                                 } else {
1336                                         keyIDKDV.setKeyDataValueBytes((byte[]) spkiDataJAXB.getValue());
1337                                 }
1338                                 spkiDataTypeKDV.getKeyDataValueList().add(keyIDKDV);
1339                         } else {
1340                                 throw new RuntimeException("Unrecognized type: " + spkiDataValue.getClass().getCanonicalName());
1341                         }
1342                 }
1343                 return spkiDataTypeKDV;
1344         }
1345 
1346         private static SignatureTransformDataValue mapSignatureTransformDataValue(Object xform) {
1347                 SignatureTransformDataValue sdv = new SignatureTransformDataValue();
1348                 if (xform instanceof String) {
1349                         sdv.setContentType(String.class.getSimpleName());
1350                         String xformStr = xform.toString();
1351                         try {
1352                                 byte[] xformBytes = xformStr.getBytes(AuthenticatedService.UTF8);
1353                                 sdv.setContentBytes(xformBytes);
1354                         } catch (Exception e) {
1355                                 throw new RuntimeException("Failed to encode string due to: " + e.getMessage(), e);
1356                         }
1357                 } else if (xform instanceof Element) {
1358                         sdv.setContentType(Element.class.getCanonicalName());
1359                         Element xformEl = (Element) xform;
1360                         String str = serializeTransformElement(xformEl);
1361                         try {
1362                                 sdv.setContentBytes(str.getBytes(AuthenticatedService.UTF8));
1363                         } catch (Exception e) {
1364                                 throw new RuntimeException("Failed to encode string due to: " + e.getMessage(), e);
1365                         }
1366                 } else if (xform instanceof byte[]) {
1367                         sdv.setContentType(byte[].class.getSimpleName());
1368                         sdv.setContentBytes((byte[]) xform);
1369                 } else if (xform instanceof JAXBElement) {
1370                         sdv.setContentType(Element.class.getCanonicalName());
1371                         JAXBElement xformJAXB = (JAXBElement) xform;
1372                         DOMResult domResult = new DOMResult();
1373                         JAXB.marshal(xformJAXB, domResult);
1374                         Element xformEl = ((Document) domResult.getNode()).getDocumentElement();
1375                         String str = serializeTransformElement(xformEl);
1376                         try {
1377                                 sdv.setContentBytes(str.getBytes(AuthenticatedService.UTF8));
1378                         } catch (Exception e) {
1379                                 throw new RuntimeException("Failed to encode string due to: " + e.getMessage(), e);
1380                         }
1381                 } else {
1382                         throw new RuntimeException("Unrecognized type: " + xform.getClass().getCanonicalName());
1383                 }
1384                 return sdv;
1385         }
1386 
1387         private static String serializeTransformElement(Element xformEl) throws DOMException, LSException {
1388                 Document document = xformEl.getOwnerDocument();
1389                 DOMImplementationLS domImplLS = (DOMImplementationLS) document.getImplementation();
1390                 LSSerializer serializer = domImplLS.createLSSerializer();
1391 //        serializer.getDomConfig().setParameter("namespaces", true);
1392 //        serializer.getDomConfig().setParameter("namespace-declarations", true);
1393                 serializer.getDomConfig().setParameter("canonical-form", false);
1394                 serializer.getDomConfig().setParameter("xml-declaration", false);
1395                 String str = serializer.writeToString(xformEl);
1396                 return str;
1397         }
1398 
1399         public static org.apache.juddi.model.ChangeRecord mapChangeRecord(ChangeRecord rec) throws UnsupportedEncodingException {
1400                 org.apache.juddi.model.ChangeRecord r = new org.apache.juddi.model.ChangeRecord();
1401                 //r.setId(rec.getChangeID().getOriginatingUSN());
1402                 r.setOriginatingUSN(rec.getChangeID().getOriginatingUSN());
1403                 if (r.getOriginatingUSN() == null) {
1404                         //       logger.warn("strange, the getOriginatingUSN is null!!");
1405                         //       JAXB.marshal(rec, System.out);
1406                         //       Thread.dumpStack();
1407                 }
1408                 r.setNodeID(rec.getChangeID().getNodeID());
1409                 if (rec.getChangeRecordNewData() != null) {
1410                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordNewData);
1411                         r.setEntityKey(rec.getChangeRecordNewData().getOperationalInfo().getEntityKey());
1412                         if (rec.getChangeRecordNewData().getOperationalInfo().getEntityKey() == null) {
1413                                 throw new UnsupportedEncodingException("entity key is null! make sure it's filled out before saving!");
1414                         }
1415                 } else if (rec.getChangeRecordAcknowledgement() != null) {
1416                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordAcknowledgement);
1417                 } else if (rec.getChangeRecordConditionFailed() != null) {
1418                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordConditionFailed);
1419                 } else if (rec.getChangeRecordCorrection() != null) {
1420                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordCorrection);
1421                 } else if (rec.getChangeRecordDelete() != null) {
1422                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordDelete);
1423                         if (rec.getChangeRecordDelete().getTModelKey() != null) {
1424                                 r.setEntityKey(rec.getChangeRecordDelete().getTModelKey());
1425                         }
1426                         if (rec.getChangeRecordDelete().getBindingKey() != null) {
1427                                 r.setEntityKey(rec.getChangeRecordDelete().getBindingKey());
1428                         }
1429                         if (rec.getChangeRecordDelete().getBusinessKey() != null) {
1430                                 r.setEntityKey(rec.getChangeRecordDelete().getBusinessKey());
1431                         }
1432                         if (rec.getChangeRecordDelete().getServiceKey() != null) {
1433                                 r.setEntityKey(rec.getChangeRecordDelete().getServiceKey());
1434                         }
1435                 } else if (rec.getChangeRecordDeleteAssertion() != null) {
1436                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordDeleteAssertion);
1437                 } else if (rec.getChangeRecordHide() != null) {
1438                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordHide);
1439                         r.setEntityKey(rec.getChangeRecordHide().getTModelKey());
1440                 } else if (rec.getChangeRecordNewDataConditional() != null) {
1441                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordNewDataConditional);
1442                 } else if (rec.getChangeRecordNull() != null) {
1443                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordNull);
1444                 } else if (rec.getChangeRecordPublisherAssertion() != null) {
1445                         r.setRecordType(org.apache.juddi.model.ChangeRecord.RecordType.ChangeRecordPublisherAssertion);
1446                 } else {
1447                         throw new UnsupportedEncodingException("unknown type!");
1448                 }
1449 
1450                 StringWriter sw = new StringWriter();
1451                 JAXB.marshal(rec, sw);
1452                 r.setContents(sw.toString().getBytes(AuthenticatedService.UTF8));
1453                 return r;
1454 
1455         }
1456 
1457         public static void mapOperationalInfo(UddiEntity model, OperationalInfo operationalInfo) {
1458                 if (operationalInfo == null || model == null) {
1459                         return;
1460                 }
1461                 if (operationalInfo.getCreated() != null) {
1462                         model.setCreated(operationalInfo.getCreated().toGregorianCalendar().getTime());
1463                 }
1464                 model.setAuthorizedName(operationalInfo.getAuthorizedName());
1465                 if (operationalInfo.getModified() != null) {
1466                         model.setModified(operationalInfo.getModified().toGregorianCalendar().getTime());
1467                 }
1468                 if (operationalInfo.getModifiedIncludingChildren() != null) {
1469                         model.setModifiedIncludingChildren(operationalInfo.getModifiedIncludingChildren().toGregorianCalendar().getTime());
1470                 }
1471                 model.setNodeId(operationalInfo.getNodeID());
1472 
1473         }
1474 
1475         public static void mapOperationalInfoIncludingChildren(BusinessEntity model, OperationalInfo operationalInfo) {
1476                 if (operationalInfo == null || model == null) {
1477                         return;
1478                 }
1479                 if (operationalInfo.getCreated() != null) {
1480                         model.setCreated(operationalInfo.getCreated().toGregorianCalendar().getTime());
1481                 }
1482                 model.setAuthorizedName(operationalInfo.getAuthorizedName());
1483                 if (operationalInfo.getModified() != null) {
1484                         model.setModified(operationalInfo.getModified().toGregorianCalendar().getTime());
1485                 }
1486                 if (operationalInfo.getModifiedIncludingChildren() != null) {
1487                         model.setModifiedIncludingChildren(operationalInfo.getModifiedIncludingChildren().toGregorianCalendar().getTime());
1488                 }
1489                 model.setNodeId(operationalInfo.getNodeID());
1490                 for (int i = 0; i < model.getBusinessServices().size(); i++) {
1491                         mapOperationalInfo(model.getBusinessServices().get(i), operationalInfo);
1492                         for (int k = 0; k < model.getBusinessServices().get(i).getBindingTemplates().size(); k++) {
1493                                 mapOperationalInfo(model.getBusinessServices().get(i).getBindingTemplates().get(k), operationalInfo);
1494                         }
1495                 }
1496 
1497         }
1498 
1499         public static void mapReplicationConfiguration(ReplicationConfiguration replicationConfiguration, org.apache.juddi.model.ReplicationConfiguration model, EntityManager em) throws DispositionReportFaultMessage {
1500                 if (replicationConfiguration == null) {
1501                         throw new ValueNotAllowedException(new ErrorMessage("errors.replication.configNull"));
1502                 }
1503                 model.setMaximumTimeToGetChanges(replicationConfiguration.getMaximumTimeToGetChanges());
1504                 model.setMaximumTimeToSyncRegistry(replicationConfiguration.getMaximumTimeToSyncRegistry());
1505                 //this is set by the service when saving
1506                 model.setSerialNumber(null);
1507 
1508                 //the spec doesn't specify what the format should be, however there was an example
1509                 //2002 03 04 1859Z
1510                 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmZ");
1511                 model.setTimeOfConfigurationUpdate(sdf.format(new Date()));
1512                 if (replicationConfiguration.getRegistryContact() != null) {
1513                         model.setContact(mapContact(replicationConfiguration.getRegistryContact().getContact(), model));
1514                 }
1515                 mapCommunicationGraph(model, replicationConfiguration.getCommunicationGraph(), em);
1516                 model.setOperator(mapOperators(replicationConfiguration, model));
1517                 if (replicationConfiguration.getSignature() != null) {
1518                         model.setSignatures(mapApiSignaturesToModelSignatures(replicationConfiguration.getSignature()));
1519                 }
1520 
1521         }
1522 
1523         private static Contact mapContact(org.uddi.api_v3.Contact contact, org.apache.juddi.model.ReplicationConfiguration model) throws DispositionReportFaultMessage {
1524                 Contact cmodel = new Contact();
1525                 cmodel.setReplicationConfigId(model);
1526                 cmodel.setAddresses(new ArrayList<Address>());
1527                 mapContactAddresses(contact.getAddress(), cmodel.getAddresses(), cmodel);
1528                 if (cmodel.getAddresses().isEmpty()) {
1529                         cmodel.setAddresses(null);
1530                 }
1531                 return cmodel;
1532         }
1533 
1534         private static List<Operator> mapOperators(ReplicationConfiguration cfg, org.apache.juddi.model.ReplicationConfiguration modelparent) throws DispositionReportFaultMessage {
1535                 if (cfg == null) {
1536                         return null;
1537                 }
1538                 List<org.uddi.repl_v3.Operator> api = cfg.getOperator();
1539                 if (api == null) {
1540                         return null;
1541                 }
1542                 List<Operator> model = new ArrayList<Operator>();
1543                 for (int i = 0; i < api.size(); i++) {
1544                         Operator op = new Operator();
1545                         op.setParent(modelparent);
1546 
1547                         op.setSoapReplicationURL(api.get(i).getSoapReplicationURL());
1548 
1549                         if (!api.get(i).getContact().isEmpty()) {
1550                                 op.setContact(new ArrayList<Contact>());
1551                                 for (int k = 0; k < api.get(i).getContact().size(); k++) {
1552                                         op.getContact().add(mapContact(api.get(i).getContact().get(k), null));
1553                                 }
1554                         }
1555                         op.setOperatorNodeID(api.get(i).getOperatorNodeID());
1556                         op.setOperatorStatus(mapOperatorStatus(api.get(i).getOperatorStatus()));
1557                         if (!api.get(i).getKeyInfo().isEmpty()) {
1558                                 op.setKeyInfo(new ArrayList<KeyInfo>());
1559                                 for (int k = 0; k < api.get(i).getKeyInfo().size(); k++) {
1560                                         org.apache.juddi.model.KeyInfo modelKeyInfo = new KeyInfo();
1561                                         modelKeyInfo.setXmlID(api.get(i).getKeyInfo().get(i).getId());
1562                                         modelKeyInfo.setKeyDataValue(new ArrayList<KeyDataValue>());
1563                                         if (api.get(i).getKeyInfo().get(i).getContent() != null) {
1564                                                 modelKeyInfo.setKeyDataValue(new ArrayList<KeyDataValue>());
1565                                                 for (int x = 0; x < api.get(i).getKeyInfo().get(k).getContent().size(); x++) {
1566                                                         mapKeyValue((JAXBElement) api.get(i).getKeyInfo().get(k).getContent().get(x), modelKeyInfo.getKeyDataValue());
1567                                                 }
1568                                         }
1569                                         op.getKeyInfo().add(modelKeyInfo);
1570                                 }
1571 
1572                         }
1573                         model.add(op);
1574 
1575                 }
1576                 return model;
1577         }
1578 
1579         private static OperatorStatusType mapOperatorStatus(org.uddi.repl_v3.OperatorStatusType operatorStatus) {
1580                 switch (operatorStatus) {
1581                         case NEW:
1582                                 return OperatorStatusType.NEW;
1583                         case NORMAL:
1584                                 return OperatorStatusType.NORMAL;
1585                         case RESIGNED:
1586                                 return OperatorStatusType.RESIGNED;
1587                 }
1588                 return null;
1589         }
1590 
1591         private static void mapCommunicationGraph(org.apache.juddi.model.ReplicationConfiguration model, CommunicationGraph communicationGraph, EntityManager em) throws ValueNotAllowedException {
1592 
1593                 if (model == null) {
1594                         return;
1595                 }
1596 
1597                 /**
1598                  * Following the listing of nodes is the controlledMessage
1599                  * element that lists the set of messages over which this
1600                  * communication graph is intended to administer control of. If
1601                  * a message element local name is listed in the
1602                  * controlledMessage element, then such messages SHALL only be
1603                  * sent between nodes that are listed in the subsequent edges of
1604                  * the graph. In contrast, communication restrictions are not
1605                  * imposed on replication messages not identified in the
1606                  * controlledMessage element.
1607                  */
1608                 if (communicationGraph.getControlledMessage() != null) {
1609                         model.setControlMessage(new ArrayList<ControlMessage>());
1610 
1611                         for (int k = 0; k < communicationGraph.getControlledMessage().size(); k++) {
1612                                 ControlMessage BC = new ControlMessage(communicationGraph.getControlledMessage().get(k));
1613                                 BC.setReplicationConfiguration(model);
1614 
1615                                 model.getControlMessage().add(BC);
1616                         }
1617                 }
1618 
1619                 for (int i = 0; i < communicationGraph.getNode().size(); i++) {
1620                         ReplicationConfigurationNode replicationConfigurationNode = new ReplicationConfigurationNode();
1621 
1622                         replicationConfigurationNode.setNodeName(communicationGraph.getNode().get(i));
1623                         replicationConfigurationNode.setParent(model);
1624                         model.getNode().add(replicationConfigurationNode);
1625                 }
1626                 if (communicationGraph.getEdge() != null && !communicationGraph.getEdge().isEmpty()) {
1627                         List<Edge> ret = new ArrayList<Edge>();
1628                         for (int i = 0; i < communicationGraph.getEdge().size(); i++) {
1629                                 Edge e = new Edge();
1630                                 e.setReplicationConfiguration(model);
1631 
1632                                 e.setMessageReceiver(communicationGraph.getEdge().get(i).getMessageReceiver());
1633                                 e.setMessageSender(communicationGraph.getEdge().get(i).getMessageSender());
1634 
1635                                 /**
1636                                  * The message elements contain the local name
1637                                  * of the Replication API message elements. They
1638                                  * indicate that only messages of the type
1639                                  * explicitly identified for a particular edge
1640                                  * MAY be sent from the specified messageSender
1641                                  * to the specified messageReceiver.
1642                                  */
1643                                 if (communicationGraph.getEdge().get(i).getMessage() != null) {
1644                                         e.setMessage(new ArrayList<ControlMessage>());
1645                                         for (int k = 0; k < communicationGraph.getEdge().get(i).getMessage().size(); k++) {
1646                                                 ControlMessage controlMessage = new ControlMessage(communicationGraph.getEdge().get(i).getMessage().get(k));
1647                                                 controlMessage.setReplicationConfiguration(model);
1648                                                 controlMessage.setParentEdge(e);
1649                                                 e.getMessages().add(controlMessage);
1650                                         }
1651                                 }
1652                                 if (communicationGraph.getEdge().get(i).getMessageReceiverAlternate() != null) {
1653                                         List<EdgeReceiverAlternate> eras = new ArrayList<EdgeReceiverAlternate>();
1654                                         for (String s : communicationGraph.getEdge().get(i).getMessageReceiverAlternate()) {
1655                                                 EdgeReceiverAlternate x = new EdgeReceiverAlternate();
1656                                                 x.setParent(e);
1657                                                 x.setReceiverAlternate(s);
1658                                                 eras.add(x);
1659                                         }
1660                                         e.setMessageReceiverAlternate(eras);
1661 
1662                                 }
1663 
1664                                 ret.add(e);
1665                         }
1666                         model.setEdge(ret);
1667                 }
1668         }
1669 
1670         public static void mapOperationalInfoIncludingChildren(BusinessService model, OperationalInfo operationalInfo) {
1671                 if (operationalInfo == null || model == null) {
1672                         return;
1673                 }
1674                 if (operationalInfo.getCreated() != null) {
1675                         model.setCreated(operationalInfo.getCreated().toGregorianCalendar().getTime());
1676                 }
1677                 model.setAuthorizedName(operationalInfo.getAuthorizedName());
1678                 if (operationalInfo.getModified() != null) {
1679                         model.setModified(operationalInfo.getModified().toGregorianCalendar().getTime());
1680                 }
1681                 if (operationalInfo.getModifiedIncludingChildren() != null) {
1682                         model.setModifiedIncludingChildren(operationalInfo.getModifiedIncludingChildren().toGregorianCalendar().getTime());
1683                 }
1684                 model.setNodeId(operationalInfo.getNodeID());
1685 
1686                 for (int k = 0; k < model.getBindingTemplates().size(); k++) {
1687                         mapOperationalInfo(model.getBindingTemplates().get(k), operationalInfo);
1688                 }
1689 
1690         }
1691 
1692 }