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.math.BigInteger;
20  import java.util.GregorianCalendar;
21  import javax.xml.datatype.DatatypeConfigurationException;
22  import javax.xml.datatype.DatatypeFactory;
23  import org.w3._2000._09.xmldsig_.X509IssuerSerialType;
24  import java.io.ByteArrayInputStream;
25  import java.io.StringReader;
26  import java.io.UnsupportedEncodingException;
27  import java.util.ArrayList;
28  import java.util.Collections;
29  import java.util.Iterator;
30  import java.util.List;
31  import java.util.logging.Level;
32  import java.util.logging.Logger;
33  import javax.persistence.EntityManager;
34  import javax.xml.bind.JAXB;
35  import javax.xml.bind.JAXBElement;
36  
37  import javax.xml.bind.JAXBException;
38  import javax.xml.namespace.QName;
39  import javax.xml.parsers.DocumentBuilder;
40  import javax.xml.parsers.DocumentBuilderFactory;
41  
42  import org.apache.commons.configuration.ConfigurationException;
43  import org.apache.commons.logging.Log;
44  import org.apache.commons.logging.LogFactory;
45  import org.apache.juddi.config.AppConfig;
46  import org.apache.juddi.config.Property;
47  import org.apache.juddi.jaxb.JAXBMarshaller;
48  import org.apache.juddi.model.CanonicalizationMethod;
49  import org.apache.juddi.model.ControlMessage;
50  import org.apache.juddi.model.Edge;
51  import org.apache.juddi.model.EdgeReceiverAlternate;
52  import org.apache.juddi.model.KeyInfo;
53  import org.apache.juddi.model.OverviewDoc;
54  import org.apache.juddi.model.Reference;
55  import org.apache.juddi.model.SignatureTransform;
56  import org.apache.juddi.model.SignatureValue;
57  import org.apache.juddi.model.SignedInfo;
58  import org.apache.juddi.model.UddiEntity;
59  import org.apache.juddi.model.KeyDataValue;
60  import org.apache.juddi.model.Node;
61  import org.apache.juddi.model.ReplicationConfiguration;
62  import org.apache.juddi.model.ReplicationConfigurationNode;
63  import org.apache.juddi.model.Signature;
64  import org.apache.juddi.model.SignatureTransformDataValue;
65  import org.apache.juddi.subscription.TypeConvertor;
66  import org.apache.juddi.v3.client.cryptor.XmlUtils;
67  import org.apache.juddi.v3.error.ErrorMessage;
68  import org.apache.juddi.v3.error.FatalErrorException;
69  import org.uddi.api_v3.BusinessEntity;
70  import org.uddi.api_v3.CompletionStatus;
71  import org.uddi.api_v3.Contact;
72  import org.uddi.api_v3.Contacts;
73  import org.uddi.api_v3.OperationalInfo;
74  import org.uddi.api_v3.PersonName;
75  import org.uddi.repl_v3.ChangeRecord;
76  import org.uddi.repl_v3.ChangeRecordIDType;
77  import org.uddi.repl_v3.CommunicationGraph;
78  import org.uddi.repl_v3.Operator;
79  import org.uddi.repl_v3.OperatorStatusType;
80  import org.uddi.sub_v3.SubscriptionFilter;
81  import org.uddi.v3_service.DispositionReportFaultMessage;
82  import org.w3._2000._09.xmldsig_.CanonicalizationMethodType;
83  import org.w3._2000._09.xmldsig_.DSAKeyValueType;
84  import org.w3._2000._09.xmldsig_.DigestMethodType;
85  import org.w3._2000._09.xmldsig_.KeyInfoType;
86  import org.w3._2000._09.xmldsig_.KeyValueType;
87  import org.w3._2000._09.xmldsig_.PGPDataType;
88  import org.w3._2000._09.xmldsig_.RSAKeyValueType;
89  import org.w3._2000._09.xmldsig_.ReferenceType;
90  import org.w3._2000._09.xmldsig_.RetrievalMethodType;
91  import org.w3._2000._09.xmldsig_.SPKIDataType;
92  import org.w3._2000._09.xmldsig_.SignatureMethodType;
93  import org.w3._2000._09.xmldsig_.SignatureType;
94  import org.w3._2000._09.xmldsig_.SignatureValueType;
95  import org.w3._2000._09.xmldsig_.SignedInfoType;
96  import org.w3._2000._09.xmldsig_.TransformType;
97  import org.w3._2000._09.xmldsig_.TransformsType;
98  import org.w3._2000._09.xmldsig_.X509DataType;
99  import org.w3c.dom.Document;
100 import org.w3c.dom.Element;
101 
102 /**
103  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
104  * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
105  */
106 public class MappingModelToApi {
107 
108         private static Log logger = LogFactory.getLog(MappingModelToApi.class);
109 
110         public static void mapPublisher(org.apache.juddi.model.Publisher modelPublisher,
111              org.apache.juddi.api_v3.Publisher apiPublisher)
112              throws DispositionReportFaultMessage {
113 
114                 apiPublisher.setAuthorizedName(modelPublisher.getAuthorizedName());
115                 apiPublisher.setPublisherName(modelPublisher.getPublisherName());
116                 apiPublisher.setEmailAddress(modelPublisher.getEmailAddress());
117                 apiPublisher.setIsAdmin(modelPublisher.getIsAdmin());
118                 apiPublisher.setIsEnabled(modelPublisher.getIsEnabled());
119                 apiPublisher.setMaxBindingsPerService(modelPublisher.getMaxBindingsPerService());
120                 apiPublisher.setMaxBusinesses(modelPublisher.getMaxBusinesses());
121                 apiPublisher.setMaxServicePerBusiness(modelPublisher.getMaxServicesPerBusiness());
122                 apiPublisher.setMaxTModels(modelPublisher.getMaxTmodels());
123                 mapSignature(modelPublisher.getSignatures(), apiPublisher.getSignature());
124         }
125 
126         public static void mapBusinessEntity(org.apache.juddi.model.BusinessEntity modelBusinessEntity,
127              org.uddi.api_v3.BusinessEntity apiBusinessEntity)
128              throws DispositionReportFaultMessage {
129 
130                 apiBusinessEntity.setBusinessKey(modelBusinessEntity.getEntityKey());
131 
132                 mapBusinessNames(modelBusinessEntity.getBusinessNames(), apiBusinessEntity.getName());
133                 mapBusinessDescriptions(modelBusinessEntity.getBusinessDescrs(), apiBusinessEntity.getDescription());
134 
135                 mapDiscoveryUrls(modelBusinessEntity.getDiscoveryUrls(), apiBusinessEntity.getDiscoveryURLs(), apiBusinessEntity);
136                 mapContacts(modelBusinessEntity.getContacts(), apiBusinessEntity.getContacts(), apiBusinessEntity);
137                 mapBusinessIdentifiers(modelBusinessEntity.getBusinessIdentifiers(), apiBusinessEntity.getIdentifierBag(), apiBusinessEntity);
138                 apiBusinessEntity.setCategoryBag(mapCategoryBag(modelBusinessEntity.getCategoryBag(), apiBusinessEntity.getCategoryBag()));
139 
140                 mapBusinessServices(modelBusinessEntity.getBusinessServices(), modelBusinessEntity.getServiceProjections(), apiBusinessEntity.getBusinessServices(), apiBusinessEntity);
141 
142                 mapSignature(modelBusinessEntity.getSignatures(), apiBusinessEntity.getSignature());
143         }
144 
145         public static void mapSignature(List<org.apache.juddi.model.Signature> signatureList,
146              List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatureList)
147              throws DispositionReportFaultMessage {
148                 apiSignatureList.clear();
149                 for (org.apache.juddi.model.Signature modelSig : signatureList) {
150                         SignatureType apiSignature = new SignatureType();
151                         apiSignature.setId(modelSig.getXmlID());
152 
153                         SignedInfo modelSignedInfo = modelSig.getSignedInfo();
154                         SignedInfoType apiSignedInfoType = new SignedInfoType();
155                         apiSignature.setSignedInfo(apiSignedInfoType);
156                         // Canonicalization method
157                         CanonicalizationMethod modelCanonMethod = modelSignedInfo.getCanonicalizationMethod();
158                         CanonicalizationMethodType apiCanonMethod = new CanonicalizationMethodType();
159                         apiCanonMethod.setAlgorithm(modelCanonMethod.getAlgorithm());
160                         apiSignedInfoType.setCanonicalizationMethod(apiCanonMethod);
161 
162                         // Signature Method
163                         String sigAlg = modelSignedInfo.getSignatureMethod().getAlgorithm();
164                         SignatureMethodType apiSigMethod = new SignatureMethodType();
165                         apiSigMethod.setAlgorithm(sigAlg);
166                         apiSignedInfoType.setSignatureMethod(apiSigMethod);
167 
168                         // References
169                         List<Reference> modelReferenceList = modelSignedInfo.getReference();
170                         List<ReferenceType> apiReferenceList = apiSignedInfoType.getReference();
171                         for (Reference modelRef : modelReferenceList) {
172                                 ReferenceType apiRef = new ReferenceType();
173                                 String refUri = modelRef.getUri();
174                                 if (refUri == null) {
175                                         refUri = "";
176                                 }
177                                 apiRef.setURI(refUri);
178 
179                                 List<SignatureTransform> modelSigTransformList = modelRef.getTransforms();
180                                 TransformsType apiTransformsType = apiRef.getTransforms();
181                                 if (apiTransformsType == null) {
182                                         apiTransformsType = new TransformsType();
183                                         apiRef.setTransforms(apiTransformsType);
184                                 }
185                                 List<TransformType> apiTransformList = apiTransformsType.getTransform();
186                                 for (SignatureTransform modelSigTransform : modelSigTransformList) {
187                                         String modelTransformAlgStr = modelSigTransform.getTransform();
188                                         TransformType apiTransform = new TransformType();
189                                         apiTransform.setAlgorithm(modelTransformAlgStr);
190 
191                                         List<SignatureTransformDataValue> sigTransformSDVList = modelSigTransform.getSignatureTransformDataValue();
192                                         for (SignatureTransformDataValue sigTransformSDV : sigTransformSDVList) {
193                                                 String type = sigTransformSDV.getContentType();
194                                                 byte[] xformBytes = sigTransformSDV.getContentBytes();
195                                                 Object transformObject = convertDataToTransformContent(type, xformBytes);
196                                                 apiTransform.getContent().add(transformObject);
197                                         }
198 
199                                         apiTransformList.add(apiTransform);
200                                 }
201 
202                                 String digestMethodStr = modelRef.getDigestMethod();
203                                 byte[] digestValBytes = modelRef.getDigestValue();
204 
205                                 DigestMethodType apiDigestMethod = new DigestMethodType();
206                                 apiDigestMethod.setAlgorithm(digestMethodStr);
207                                 apiRef.setDigestMethod(apiDigestMethod);
208                                 apiRef.setDigestValue(digestValBytes);
209 
210                                 apiReferenceList.add(apiRef);
211                         }
212 
213                         // Signature Value
214                         SignatureValueType apiSignatureValue = new SignatureValueType();
215                         SignatureValue modelSigValue = modelSig.getSignatureValue();
216                         apiSignatureValue.setId(modelSigValue.getXmlID());
217                         apiSignatureValue.setValue(modelSigValue.getValue());
218 
219                         apiSignature.setSignatureValue(apiSignatureValue);
220 
221                         KeyInfoType apiKeyInfo = new KeyInfoType();
222                         KeyInfo modelKeyInfo = modelSig.getKeyInfo();
223                         apiKeyInfo.setId(modelKeyInfo.getXmlID());
224 
225                         List<KeyDataValue> modelKeyDataValueList = modelKeyInfo.getKeyDataValue();
226                         List<Object> apiX509KeyInfoList = apiKeyInfo.getContent();
227                         mapModelKeyDataValue(modelKeyDataValueList, apiX509KeyInfoList);
228                         apiSignature.setKeyInfo(apiKeyInfo);
229                         apiSignatureList.add(apiSignature);
230                 }
231         }
232 
233         private static void mapModelKeyDataValue(List<KeyDataValue> modelKeyDataValueList, List<Object> parentKeyDataList) {
234                 for (KeyDataValue modelKeyDataValue : modelKeyDataValueList) {
235                         String tagName = modelKeyDataValue.getKeyDataName();
236                         String dataType = modelKeyDataValue.getKeyDataType();
237                         byte[] contentBytes = modelKeyDataValue.getKeyDataValueBytes();
238                         String contentStr = modelKeyDataValue.getKeyDataValueString();
239                         Object contents = contentBytes != null ? contentBytes : contentStr;
240 
241                         if (contents == null) {
242                                 List<Object> childKeyDataList = new ArrayList<Object>();
243                                 if (dataType.equals(X509DataType.class.getSimpleName())) {
244                                         X509DataType x509DataType = new X509DataType();
245                                         mapModelKeyDataValue(modelKeyDataValue.getKeyDataValueList(), childKeyDataList);
246                                         x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().addAll(childKeyDataList);
247                                         JAXBElement dataJAXB = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", tagName), X509DataType.class, x509DataType);
248                                         parentKeyDataList.add(dataJAXB);
249                                 } else if (dataType.equals(RetrievalMethodType.class.getSimpleName())) {
250                                         RetrievalMethodType retrievalMethodType = new RetrievalMethodType();
251                                         TransformsType transformsType = new TransformsType();
252                                         for (KeyDataValue retrievalMethodKDV : modelKeyDataValue.getKeyDataValueList()) {
253                                                 if (retrievalMethodKDV.getKeyDataName().equals("Transform")) {
254                                                         TransformType tType = new TransformType();
255                                                         tType.setAlgorithm(retrievalMethodKDV.getKeyDataValueString());
256 
257                                                         for (KeyDataValue transformContentKDV : retrievalMethodKDV.getKeyDataValueList()) {
258                                                                 String type = transformContentKDV.getKeyDataType();
259                                                                 byte[] xformBytes = transformContentKDV.getKeyDataValueBytes();
260                                                                 Object transformObject = convertDataToTransformContent(type, xformBytes);
261                                                                 tType.getContent().add(transformObject);
262                                                         }
263 
264                                                         transformsType.getTransform().add(tType);
265                                                 } else if (retrievalMethodKDV.getKeyDataName().equals("Type")) {
266                                                         retrievalMethodType.setType(retrievalMethodKDV.getKeyDataValueString());
267                                                 } else if (retrievalMethodKDV.getKeyDataName().equals("URI")) {
268                                                         retrievalMethodType.setURI(retrievalMethodKDV.getKeyDataValueString());
269                                                 } else {
270                                                         throw new RuntimeException("Unrecognized key data type: " + retrievalMethodKDV.getKeyDataType());
271                                                 }
272                                         }
273                                         if (transformsType.getTransform() != null && !transformsType.getTransform().isEmpty()) {
274                                                 retrievalMethodType.setTransforms(transformsType);
275                                         }
276                                         JAXBElement dataJAXB = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", tagName), RetrievalMethodType.class, retrievalMethodType);
277                                         parentKeyDataList.add(dataJAXB);
278                                 } else if (dataType.equals(PGPDataType.class.getSimpleName())) {
279                                         PGPDataType pgpDataType = new PGPDataType();
280 
281                                         for (KeyDataValue pgpDataKDV : modelKeyDataValue.getKeyDataValueList()) {
282                                                 String pgpDataTagName = pgpDataKDV.getKeyDataName();
283                                                 Object pgpDataContents = pgpDataKDV.getKeyDataValueBytes() != null ? pgpDataKDV.getKeyDataValueBytes() : pgpDataKDV.getKeyDataValueString();
284                                                 Class pgpDataClazz = pgpDataContents.getClass();
285                                                 JAXBElement jaxb = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", pgpDataTagName), pgpDataClazz, pgpDataContents);
286                                                 pgpDataType.getContent().add(jaxb);
287                                         }
288 
289                                         JAXBElement dataJAXB = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", tagName), PGPDataType.class, pgpDataType);
290                                         parentKeyDataList.add(dataJAXB);
291                                 } else if (dataType.equals(SPKIDataType.class.getSimpleName())) {
292                                         SPKIDataType spkiDataType = new SPKIDataType();
293 
294                                         for (KeyDataValue spkiDataKDV : modelKeyDataValue.getKeyDataValueList()) {
295                                                 String spkiDataTagName = spkiDataKDV.getKeyDataName();
296                                                 Object spkiDataContents = spkiDataKDV.getKeyDataValueBytes() != null ? spkiDataKDV.getKeyDataValueBytes() : spkiDataKDV.getKeyDataValueString();
297                                                 Class spkiDataClazz = spkiDataContents.getClass();
298                                                 JAXBElement jaxb = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", spkiDataTagName), spkiDataClazz, spkiDataContents);
299                                                 spkiDataType.getSPKISexpAndAny().add(jaxb);
300                                         }
301 
302                                         JAXBElement dataJAXB = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", tagName), SPKIDataType.class, spkiDataType);
303                                         parentKeyDataList.add(dataJAXB);
304                                 } else if (dataType.equals(KeyValueType.class.getSimpleName())) {
305                                         KeyValueType keyValueType = new KeyValueType();
306                                         for (KeyDataValue keyValueDataKDV : modelKeyDataValue.getKeyDataValueList()) {
307                                                 for (KeyDataValue keyValueDataChildKDV : keyValueDataKDV.getKeyDataValueList()) {
308                                                         String keyDataDataType = keyValueDataChildKDV.getKeyDataType();
309                                                         if (keyDataDataType.equals("DSAKeyValueType")) {
310                                                                 DSAKeyValueType dsaKeyValueType = new DSAKeyValueType();
311                                                                 for (KeyDataValue dsaKDV : keyValueDataChildKDV.getKeyDataValueList()) {
312                                                                         if ("G".equals(dsaKDV.getKeyDataName())) {
313                                                                                 dsaKeyValueType.setG(dsaKDV.getKeyDataValueBytes());
314                                                                         } else if ("P".equals(dsaKDV.getKeyDataName())) {
315                                                                                 dsaKeyValueType.setP(dsaKDV.getKeyDataValueBytes());
316                                                                         } else if ("Q".equals(dsaKDV.getKeyDataName())) {
317                                                                                 dsaKeyValueType.setQ(dsaKDV.getKeyDataValueBytes());
318                                                                         } else if ("Y".equals(dsaKDV.getKeyDataName())) {
319                                                                                 dsaKeyValueType.setY(dsaKDV.getKeyDataValueBytes());
320                                                                         } else if ("J".equals(dsaKDV.getKeyDataName())) {
321                                                                                 dsaKeyValueType.setJ(dsaKDV.getKeyDataValueBytes());
322                                                                         } else if ("Seed".equals(dsaKDV.getKeyDataName())) {
323                                                                                 dsaKeyValueType.setSeed(dsaKDV.getKeyDataValueBytes());
324                                                                         } else if ("PgenCounter".equals(dsaKDV.getKeyDataName())) {
325                                                                                 dsaKeyValueType.setPgenCounter(dsaKDV.getKeyDataValueBytes());
326                                                                         } else {
327                                                                                 throw new RuntimeException("Unrecognized dsa type: " + dsaKDV.getKeyDataName());
328                                                                         }
329                                                                 }
330                                                                 JAXBElement jaxb = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", keyValueDataChildKDV.getKeyDataName()), DSAKeyValueType.class, dsaKeyValueType);
331                                                                 keyValueType.getContent().add(jaxb);
332                                                         } else if (keyDataDataType.equals("RSAKeyValueType")) {
333                                                                 RSAKeyValueType rsaKeyValueType = new RSAKeyValueType();
334                                                                 for (KeyDataValue rsaKDV : keyValueDataChildKDV.getKeyDataValueList()) {
335                                                                         if ("Exponent".equals(rsaKDV.getKeyDataName())) {
336                                                                                 rsaKeyValueType.setExponent(rsaKDV.getKeyDataValueBytes());
337                                                                         } else if ("Modulus".equals(rsaKDV.getKeyDataName())) {
338                                                                                 rsaKeyValueType.setModulus(rsaKDV.getKeyDataValueBytes());
339                                                                         } else {
340                                                                                 throw new RuntimeException("Unrecognized dsa type: " + rsaKDV.getKeyDataName());
341                                                                         }
342                                                                 }
343                                                                 JAXBElement jaxb = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", keyValueDataChildKDV.getKeyDataName()), RSAKeyValueType.class, rsaKeyValueType);
344                                                                 keyValueType.getContent().add(jaxb);
345                                                         } else {
346                                                                 throw new RuntimeException("Unrecognized element: " + keyDataDataType);
347                                                         }
348                                                 }
349                                         }
350                                         JAXBElement dataJAXB = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", tagName), KeyValueType.class, keyValueType);
351                                         parentKeyDataList.add(dataJAXB);
352                                 } else {
353                                         throw new RuntimeException("Unrecognized type: " + dataType);
354                                 }
355                         } else {
356                                 if (dataType != null && dataType.equals(X509IssuerSerialType.class.getSimpleName())) {
357                                         X509IssuerSerialType x509IssuerSerialType = new X509IssuerSerialType();
358                                         x509IssuerSerialType.setX509IssuerName(contentStr);
359                                         x509IssuerSerialType.setX509SerialNumber(new BigInteger(contentBytes));
360                                         JAXBElement dataJAXB = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", tagName), X509IssuerSerialType.class, x509IssuerSerialType);
361                                         parentKeyDataList.add(dataJAXB);
362                                 } else {
363                                         JAXBElement dataJAXB = new JAXBElement(new QName("http://www.w3.org/2000/09/xmldsig#", tagName), contents.getClass(), contents);
364                                         parentKeyDataList.add(dataJAXB);
365                                 }
366                         }
367                 }
368         }
369 
370         public static void mapBusinessNames(List<org.apache.juddi.model.BusinessName> modelNameList,
371              List<org.uddi.api_v3.Name> apiNameList)
372              throws DispositionReportFaultMessage {
373                 apiNameList.clear();
374 
375                 for (org.apache.juddi.model.BusinessName modelName : modelNameList) {
376                         org.uddi.api_v3.Name apiName = new org.uddi.api_v3.Name();
377                         apiName.setLang(modelName.getLangCode());
378                         apiName.setValue(modelName.getName());
379                         apiNameList.add(apiName);
380                 }
381         }
382 
383         public static void mapBusinessDescriptions(List<org.apache.juddi.model.BusinessDescr> modelDescList,
384              List<org.uddi.api_v3.Description> apiDescList)
385              throws DispositionReportFaultMessage {
386                 apiDescList.clear();
387 
388                 for (org.apache.juddi.model.BusinessDescr modelDesc : modelDescList) {
389                         org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
390                         apiDesc.setLang(modelDesc.getLangCode());
391                         apiDesc.setValue(modelDesc.getDescr());
392                         apiDescList.add(apiDesc);
393                 }
394         }
395 
396         public static void mapDiscoveryUrls(List<org.apache.juddi.model.DiscoveryUrl> modelDiscUrlList,
397              org.uddi.api_v3.DiscoveryURLs apiDiscUrls,
398              org.uddi.api_v3.BusinessEntity apiBusinessEntity)
399              throws DispositionReportFaultMessage {
400                 if (modelDiscUrlList == null || modelDiscUrlList.size() == 0) {
401                         return;
402                 }
403 
404                 if (apiDiscUrls == null) {
405                         apiDiscUrls = new org.uddi.api_v3.DiscoveryURLs();
406                 }
407 
408                 List<org.uddi.api_v3.DiscoveryURL> apiDiscUrlList = apiDiscUrls.getDiscoveryURL();
409                 apiDiscUrlList.clear();
410 
411                 for (org.apache.juddi.model.DiscoveryUrl modelDiscUrl : modelDiscUrlList) {
412                         org.uddi.api_v3.DiscoveryURL apiDiscUrl = new org.uddi.api_v3.DiscoveryURL();
413                         apiDiscUrl.setUseType(modelDiscUrl.getUseType());
414                         String discoveryURL = modelDiscUrl.getUrl();
415                         try {
416                                 String baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL);
417                                 if (baseUrl == null) {
418                                         logger.warn("Token '" + Property.JUDDI_BASE_URL + "' not found in the juddiv3.xml, defaulting to '"
419                                              + Property.DEFAULT_BASE_URL + "'");
420                                         baseUrl = Property.DEFAULT_BASE_URL;
421                                 }
422                                 discoveryURL = discoveryURL.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL + "\\}", baseUrl);
423 
424                                 baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL_SECURE);
425                                 if (baseUrl == null) {
426                                         logger.warn("Token '" + Property.JUDDI_BASE_URL_SECURE + "' not found in the juddiv3.xml, defaulting to '"
427                                              + Property.JUDDI_BASE_URL_SECURE + "'");
428                                         baseUrl = Property.DEFAULT_BASE_URL_SECURE;
429                                 }
430                                 discoveryURL = discoveryURL.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL_SECURE + "\\}", baseUrl);
431 
432                         } catch (ConfigurationException e) {
433                                 logger.error(e.getMessage(), e);
434                         }
435                         apiDiscUrl.setValue(discoveryURL);
436                         apiDiscUrlList.add(apiDiscUrl);
437                 }
438                 apiBusinessEntity.setDiscoveryURLs(apiDiscUrls);
439         }
440         
441         public static void mapContact(org.apache.juddi.model.Contact modelContact,
442                 org.uddi.api_v3.Contact apiContact) throws DispositionReportFaultMessage {
443                 if (apiContact == null) {
444                         apiContact = new org.uddi.api_v3.Contact();
445                 }
446                 apiContact.setUseType(modelContact.getUseType());
447 
448                 mapPersonNames(modelContact.getPersonNames(), apiContact.getPersonName());
449                 mapContactDescriptions(modelContact.getContactDescrs(), apiContact.getDescription());
450                 mapContactEmails(modelContact.getEmails(), apiContact.getEmail());
451                 mapContactPhones(modelContact.getPhones(), apiContact.getPhone());
452                 mapContactAddresses(modelContact.getAddresses(), apiContact.getAddress());
453 
454         }
455 
456         public static void mapContacts(List<org.apache.juddi.model.Contact> modelContactList,
457              org.uddi.api_v3.Contacts apiContacts,
458              org.uddi.api_v3.BusinessEntity apiBusinessEntity)
459              throws DispositionReportFaultMessage {
460                 if (modelContactList == null || modelContactList.size() == 0) {
461                         return;
462                 }
463 
464                 if (apiContacts == null) {
465                         apiContacts = new org.uddi.api_v3.Contacts();
466                 }
467 
468                 List<org.uddi.api_v3.Contact> apiContactList = apiContacts.getContact();
469                 apiContactList.clear();
470 
471                 for (org.apache.juddi.model.Contact modelContact : modelContactList) {
472                         org.uddi.api_v3.Contact apiContact = new org.uddi.api_v3.Contact();
473                         
474                         mapContact(modelContact,apiContact);
475                       
476                         apiContactList.add(apiContact);
477                 }
478                 apiBusinessEntity.setContacts(apiContacts);
479         }
480 
481         public static void mapContactDescriptions(List<org.apache.juddi.model.ContactDescr> modelDescList,
482              List<org.uddi.api_v3.Description> apiDescList)
483              throws DispositionReportFaultMessage {
484                 apiDescList.clear();
485 
486                 for (org.apache.juddi.model.ContactDescr modelDesc : modelDescList) {
487                         org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
488                         apiDesc.setLang(modelDesc.getLangCode());
489                         apiDesc.setValue(modelDesc.getDescr());
490                         apiDescList.add(apiDesc);
491                 }
492         }
493 
494         public static void mapPersonNames(List<org.apache.juddi.model.PersonName> modelPersonNameList,
495              List<org.uddi.api_v3.PersonName> apiPersonNameList)
496              throws DispositionReportFaultMessage {
497                 apiPersonNameList.clear();
498 
499                 for (org.apache.juddi.model.PersonName personName : modelPersonNameList) {
500                         org.uddi.api_v3.PersonName apiPersonName = new org.uddi.api_v3.PersonName();
501                         apiPersonName.setLang(personName.getLangCode());
502                         apiPersonName.setValue(personName.getName());
503                         apiPersonNameList.add(apiPersonName);
504                 }
505         }
506 
507         public static void mapContactEmails(List<org.apache.juddi.model.Email> modelEmailList,
508              List<org.uddi.api_v3.Email> apiEmailList)
509              throws DispositionReportFaultMessage {
510                 apiEmailList.clear();
511 
512                 for (org.apache.juddi.model.Email modelEmail : modelEmailList) {
513                         org.uddi.api_v3.Email apiEmail = new org.uddi.api_v3.Email();
514                         apiEmail.setUseType(modelEmail.getUseType());
515                         apiEmail.setValue(modelEmail.getEmailAddress());
516                         apiEmailList.add(apiEmail);
517                 }
518         }
519 
520         public static void mapContactPhones(List<org.apache.juddi.model.Phone> modelPhoneList,
521              List<org.uddi.api_v3.Phone> apiPhoneList)
522              throws DispositionReportFaultMessage {
523                 apiPhoneList.clear();
524 
525                 for (org.apache.juddi.model.Phone modelPhone : modelPhoneList) {
526                         org.uddi.api_v3.Phone apiPhone = new org.uddi.api_v3.Phone();
527                         apiPhone.setUseType(modelPhone.getUseType());
528                         apiPhone.setValue(modelPhone.getPhoneNumber());
529                         apiPhoneList.add(apiPhone);
530                 }
531         }
532 
533         public static void mapContactAddresses(List<org.apache.juddi.model.Address> modelAddressList,
534              List<org.uddi.api_v3.Address> apiAddressList)
535              throws DispositionReportFaultMessage {
536                 apiAddressList.clear();
537 
538                 for (org.apache.juddi.model.Address modelAddress : modelAddressList) {
539                         org.uddi.api_v3.Address apiAddress = new org.uddi.api_v3.Address();
540                         apiAddress.setUseType(modelAddress.getUseType());
541                         apiAddress.setLang("");
542                         apiAddress.setSortCode(modelAddress.getSortCode());
543                         apiAddress.setTModelKey(modelAddress.getTmodelKey());
544 
545                         mapAddressLines(modelAddress.getAddressLines(), apiAddress.getAddressLine());
546 
547                         apiAddressList.add(apiAddress);
548                 }
549         }
550 
551         public static void mapAddressLines(List<org.apache.juddi.model.AddressLine> modelAddressLineList,
552              List<org.uddi.api_v3.AddressLine> apiAddressLineList)
553              throws DispositionReportFaultMessage {
554                 apiAddressLineList.clear();
555 
556                 for (org.apache.juddi.model.AddressLine modelAddressLine : modelAddressLineList) {
557                         org.uddi.api_v3.AddressLine apiAddressLine = new org.uddi.api_v3.AddressLine();
558                         apiAddressLine.setKeyName(modelAddressLine.getKeyName());
559                         apiAddressLine.setKeyValue(modelAddressLine.getKeyValue());
560                         apiAddressLine.setValue(modelAddressLine.getLine());
561                         apiAddressLineList.add(apiAddressLine);
562                 }
563         }
564 
565         public static void mapBusinessIdentifiers(List<org.apache.juddi.model.BusinessIdentifier> modelIdentifierList,
566              org.uddi.api_v3.IdentifierBag apiIdentifierBag,
567              org.uddi.api_v3.BusinessEntity apiBusinessEntity)
568              throws DispositionReportFaultMessage {
569                 if (modelIdentifierList == null || modelIdentifierList.size() == 0) {
570                         return;
571                 }
572 
573                 if (apiIdentifierBag == null) {
574                         apiIdentifierBag = new org.uddi.api_v3.IdentifierBag();
575                 }
576 
577                 List<org.uddi.api_v3.KeyedReference> apiKeyedRefList = apiIdentifierBag.getKeyedReference();
578                 apiKeyedRefList.clear();
579 
580                 for (org.apache.juddi.model.BusinessIdentifier modelIdentifier : modelIdentifierList) {
581                         org.uddi.api_v3.KeyedReference apiKeyedRef = new org.uddi.api_v3.KeyedReference();
582                         apiKeyedRef.setTModelKey(modelIdentifier.getTmodelKeyRef());
583                         apiKeyedRef.setKeyName(modelIdentifier.getKeyName());
584                         apiKeyedRef.setKeyValue(modelIdentifier.getKeyValue());
585                         apiKeyedRefList.add(apiKeyedRef);
586                 }
587                 apiBusinessEntity.setIdentifierBag(apiIdentifierBag);
588         }
589 
590         public static void mapBusinessServices(List<org.apache.juddi.model.BusinessService> modelBusinessServiceList,
591              List<org.apache.juddi.model.ServiceProjection> modelServiceProjectionList,
592              org.uddi.api_v3.BusinessServices apiBusinessServices,
593              org.uddi.api_v3.BusinessEntity apiBusinessEntity)
594              throws DispositionReportFaultMessage {
595 
596                 if (apiBusinessServices == null) {
597                         apiBusinessServices = new org.uddi.api_v3.BusinessServices();
598                 }
599 
600                 List<org.uddi.api_v3.BusinessService> apiBusinessServiceList = apiBusinessServices.getBusinessService();
601                 apiBusinessServiceList.clear();
602 
603                 if (modelBusinessServiceList != null && modelBusinessServiceList.size() > 0) {
604                         for (org.apache.juddi.model.BusinessService modelBusinessService : modelBusinessServiceList) {
605                                 org.uddi.api_v3.BusinessService apiBusinessService = new org.uddi.api_v3.BusinessService();
606                                 mapBusinessService(modelBusinessService, apiBusinessService);
607                                 apiBusinessServiceList.add(apiBusinessService);
608                         }
609                 }
610 
611                 if (modelServiceProjectionList != null && modelServiceProjectionList.size() > 0) {
612                         for (org.apache.juddi.model.ServiceProjection modelServiceProjection : modelServiceProjectionList) {
613                                 org.uddi.api_v3.BusinessService apiBusinessService = new org.uddi.api_v3.BusinessService();
614                                 mapBusinessService(modelServiceProjection.getBusinessService(), apiBusinessService);
615                                 apiBusinessServiceList.add(apiBusinessService);
616                         }
617                 }
618 
619                 if (apiBusinessServiceList.size() > 0) {
620                         apiBusinessEntity.setBusinessServices(apiBusinessServices);
621                 }
622         }
623 
624         public static void mapBusinessService(org.apache.juddi.model.BusinessService modelBusinessService,
625              org.uddi.api_v3.BusinessService apiBusinessService)
626              throws DispositionReportFaultMessage {
627 
628                 apiBusinessService.setBusinessKey(modelBusinessService.getBusinessEntity().getEntityKey());
629                 apiBusinessService.setServiceKey(modelBusinessService.getEntityKey());
630 
631                 mapServiceNames(modelBusinessService.getServiceNames(), apiBusinessService.getName());
632                 mapServiceDescriptions(modelBusinessService.getServiceDescrs(), apiBusinessService.getDescription());
633                 mapBindingTemplates(modelBusinessService.getBindingTemplates(), apiBusinessService.getBindingTemplates(), apiBusinessService);
634                 apiBusinessService.setCategoryBag(mapCategoryBag(modelBusinessService.getCategoryBag(), apiBusinessService.getCategoryBag()));
635 
636                 mapSignature(modelBusinessService.getSignatures(), apiBusinessService.getSignature());
637         }
638 
639         public static void mapServiceNames(List<org.apache.juddi.model.ServiceName> modelNameList,
640              List<org.uddi.api_v3.Name> apiNameList)
641              throws DispositionReportFaultMessage {
642                 apiNameList.clear();
643 
644                 for (org.apache.juddi.model.ServiceName modelName : modelNameList) {
645                         org.uddi.api_v3.Name apiName = new org.uddi.api_v3.Name();
646                         apiName.setLang(modelName.getLangCode());
647                         apiName.setValue(modelName.getName());
648                         apiNameList.add(apiName);
649                 }
650         }
651 
652         public static void mapServiceDescriptions(List<org.apache.juddi.model.ServiceDescr> modelDescList,
653              List<org.uddi.api_v3.Description> apiDescList)
654              throws DispositionReportFaultMessage {
655                 apiDescList.clear();
656 
657                 for (org.apache.juddi.model.ServiceDescr modelDesc : modelDescList) {
658                         org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
659                         apiDesc.setLang(modelDesc.getLangCode());
660                         apiDesc.setValue(modelDesc.getDescr());
661                         apiDescList.add(apiDesc);
662                 }
663         }
664 
665         public static void mapBindingTemplates(List<org.apache.juddi.model.BindingTemplate> modelBindingTemplateList,
666              org.uddi.api_v3.BindingTemplates apiBindingTemplates,
667              org.uddi.api_v3.BusinessService apiBusinessService)
668              throws DispositionReportFaultMessage {
669                 if (modelBindingTemplateList == null || modelBindingTemplateList.size() == 0) {
670                         return;
671                 }
672 
673                 if (apiBindingTemplates == null) {
674                         apiBindingTemplates = new org.uddi.api_v3.BindingTemplates();
675                 }
676 
677                 List<org.uddi.api_v3.BindingTemplate> apiBindingTemplateList = apiBindingTemplates.getBindingTemplate();
678                 apiBindingTemplateList.clear();
679 
680                 for (org.apache.juddi.model.BindingTemplate modelBindingTemplate : modelBindingTemplateList) {
681                         org.uddi.api_v3.BindingTemplate apiBindingTemplate = new org.uddi.api_v3.BindingTemplate();
682                         mapBindingTemplate(modelBindingTemplate, apiBindingTemplate);
683                         apiBindingTemplateList.add(apiBindingTemplate);
684                 }
685                 apiBusinessService.setBindingTemplates(apiBindingTemplates);
686         }
687 
688         public static void mapBindingTemplate(org.apache.juddi.model.BindingTemplate modelBindingTemplate,
689              org.uddi.api_v3.BindingTemplate apiBindingTemplate)
690              throws DispositionReportFaultMessage {
691 
692                 apiBindingTemplate.setServiceKey(modelBindingTemplate.getBusinessService().getEntityKey());
693                 apiBindingTemplate.setBindingKey(modelBindingTemplate.getEntityKey());
694                 org.uddi.api_v3.AccessPoint apiAccessPoint = new org.uddi.api_v3.AccessPoint();
695                 apiAccessPoint.setUseType(modelBindingTemplate.getAccessPointType());
696                 String accessPointValue = modelBindingTemplate.getAccessPointUrl();
697                 if (accessPointValue != null) {
698                         try {
699                                 String baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL);
700                                 if (baseUrl == null) {
701                                         logger.warn("Token '" + Property.JUDDI_BASE_URL + "' not found in the juddiv3.xml, defaulting to '"
702                                              + Property.DEFAULT_BASE_URL + "'");
703                                         baseUrl = Property.DEFAULT_BASE_URL;
704                                 }
705                                 accessPointValue = accessPointValue.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL + "\\}", baseUrl);
706 
707                                 baseUrl = AppConfig.getConfiguration().getString(Property.JUDDI_BASE_URL_SECURE);
708                                 if (baseUrl == null) {
709                                         logger.warn("Token '" + Property.JUDDI_BASE_URL_SECURE + "' not found in the juddiv3.xml, defaulting to '"
710                                              + Property.JUDDI_BASE_URL_SECURE + "'");
711                                         baseUrl = Property.DEFAULT_BASE_URL_SECURE;
712                                 }
713                                 accessPointValue = accessPointValue.replaceAll("\\$\\{" + Property.JUDDI_BASE_URL_SECURE + "\\}", baseUrl);
714                         } catch (ConfigurationException e) {
715                                 logger.error(e.getMessage(), e);
716                         }
717                 }
718                 apiAccessPoint.setValue(accessPointValue);
719                 apiBindingTemplate.setAccessPoint(apiAccessPoint);
720                 if (modelBindingTemplate.getHostingRedirector() != null) {
721                         org.uddi.api_v3.HostingRedirector apiHost = new org.uddi.api_v3.HostingRedirector();
722                         apiHost.setBindingKey(modelBindingTemplate.getHostingRedirector());
723                         apiBindingTemplate.setHostingRedirector(apiHost);
724                 }
725                 mapTModelInstanceDetails(modelBindingTemplate.getTmodelInstanceInfos(), apiBindingTemplate.getTModelInstanceDetails(), apiBindingTemplate);
726                 mapBindingDescriptions(modelBindingTemplate.getBindingDescrs(), apiBindingTemplate.getDescription());
727 
728                 apiBindingTemplate.setCategoryBag(mapCategoryBag(modelBindingTemplate.getCategoryBag(), apiBindingTemplate.getCategoryBag()));
729                 mapSignature(modelBindingTemplate.getSignatures(), apiBindingTemplate.getSignature());
730         }
731 
732         public static void mapBindingDescriptions(List<org.apache.juddi.model.BindingDescr> modelDescList,
733              List<org.uddi.api_v3.Description> apiDescList)
734              throws DispositionReportFaultMessage {
735                 apiDescList.clear();
736 
737                 for (org.apache.juddi.model.BindingDescr modelDesc : modelDescList) {
738                         org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
739                         apiDesc.setLang(modelDesc.getLangCode());
740                         apiDesc.setValue(modelDesc.getDescr());
741                         apiDescList.add(apiDesc);
742                 }
743         }
744 
745         public static org.uddi.api_v3.CategoryBag mapCategoryBag(org.apache.juddi.model.CategoryBag modelCategoryBag,
746              org.uddi.api_v3.CategoryBag apiCategoryBag)
747              throws DispositionReportFaultMessage {
748 
749                 if (modelCategoryBag != null) {
750                         if (apiCategoryBag == null) {
751                                 apiCategoryBag = new org.uddi.api_v3.CategoryBag();
752                         }
753 
754                         for (org.apache.juddi.model.KeyedReference modelKeyedReference : modelCategoryBag.getKeyedReferences()) {
755                                 org.uddi.api_v3.KeyedReference apiKeyedReference = new org.uddi.api_v3.KeyedReference();
756                                 apiKeyedReference.setTModelKey(modelKeyedReference.getTmodelKeyRef());
757                                 apiKeyedReference.setKeyName(modelKeyedReference.getKeyName());
758                                 apiKeyedReference.setKeyValue(modelKeyedReference.getKeyValue());
759                                 apiCategoryBag.getKeyedReference().add(apiKeyedReference);
760                         }
761                         for (org.apache.juddi.model.KeyedReferenceGroup modelKeyedReferenceGroup : modelCategoryBag.getKeyedReferenceGroups()) {
762                                 org.uddi.api_v3.KeyedReferenceGroup apiKeyedReferenceGroup = new org.uddi.api_v3.KeyedReferenceGroup();
763 
764                                 mapKeyedReferenceGroup(modelKeyedReferenceGroup, apiKeyedReferenceGroup);
765 
766                                 apiCategoryBag.getKeyedReferenceGroup().add(apiKeyedReferenceGroup);
767                         }
768                 }
769                 return apiCategoryBag;
770         }
771 
772         public static void mapKeyedReferenceGroup(org.apache.juddi.model.KeyedReferenceGroup modelKeyedReferenceGroup,
773              org.uddi.api_v3.KeyedReferenceGroup apiKeyedReferenceGroup)
774              throws DispositionReportFaultMessage {
775 
776                 apiKeyedReferenceGroup.setTModelKey(modelKeyedReferenceGroup.getTmodelKey());
777 
778                 for (org.apache.juddi.model.KeyedReference modelKeyedReference : modelKeyedReferenceGroup.getKeyedReferences()) {
779                         org.uddi.api_v3.KeyedReference apiKeyedReference = new org.uddi.api_v3.KeyedReference();
780                         apiKeyedReference.setTModelKey(modelKeyedReference.getTmodelKeyRef());
781                         apiKeyedReference.setKeyName(modelKeyedReference.getKeyName());
782                         apiKeyedReference.setKeyValue(modelKeyedReference.getKeyValue());
783                         apiKeyedReferenceGroup.getKeyedReference().add(apiKeyedReference);
784                 }
785 
786         }
787 
788         public static void mapTModelInstanceDetails(List<org.apache.juddi.model.TmodelInstanceInfo> modelTModelInstInfoList,
789              org.uddi.api_v3.TModelInstanceDetails apiTModelInstDetails,
790              org.uddi.api_v3.BindingTemplate apiBindingTemplate)
791              throws DispositionReportFaultMessage {
792                 if (modelTModelInstInfoList == null || modelTModelInstInfoList.size() == 0) {
793                         return;
794                 }
795 
796                 if (apiTModelInstDetails == null) {
797                         apiTModelInstDetails = new org.uddi.api_v3.TModelInstanceDetails();
798                 }
799 
800                 List<org.uddi.api_v3.TModelInstanceInfo> apiTModelInstInfoList = apiTModelInstDetails.getTModelInstanceInfo();
801                 apiTModelInstInfoList.clear();
802 
803                 for (org.apache.juddi.model.TmodelInstanceInfo modelTModelInstInfo : modelTModelInstInfoList) {
804                         org.uddi.api_v3.TModelInstanceInfo apiTModelInstInfo = new org.uddi.api_v3.TModelInstanceInfo();
805                         apiTModelInstInfo.setTModelKey(modelTModelInstInfo.getTmodelKey());
806                         mapTModelInstanceInfoDescriptions(modelTModelInstInfo.getTmodelInstanceInfoDescrs(), apiTModelInstInfo.getDescription());
807                         mapInstanceDetails(modelTModelInstInfo, apiTModelInstInfo.getInstanceDetails(), apiTModelInstInfo);
808 
809                         apiTModelInstInfoList.add(apiTModelInstInfo);
810                 }
811                 apiBindingTemplate.setTModelInstanceDetails(apiTModelInstDetails);
812         }
813 
814         public static void mapTModelInstanceInfoDescriptions(List<org.apache.juddi.model.TmodelInstanceInfoDescr> modelDescList,
815              List<org.uddi.api_v3.Description> apiDescList)
816              throws DispositionReportFaultMessage {
817                 apiDescList.clear();
818 
819                 for (org.apache.juddi.model.TmodelInstanceInfoDescr modelDesc : modelDescList) {
820                         org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
821                         apiDesc.setLang(modelDesc.getLangCode());
822                         apiDesc.setValue(modelDesc.getDescr());
823                         apiDescList.add(apiDesc);
824                 }
825         }
826 
827         public static void mapInstanceDetails(org.apache.juddi.model.TmodelInstanceInfo modelTModelInstInfo,
828              org.uddi.api_v3.InstanceDetails apiInstanceDetails,
829              org.uddi.api_v3.TModelInstanceInfo apiTModelInstInfo)
830              throws DispositionReportFaultMessage {
831                 if (modelTModelInstInfo == null
832                      || (modelTModelInstInfo.getInstanceParms() == null && modelTModelInstInfo.getOverviewDocs().size() == 0)) {
833                         return;
834                 }
835 
836                 if (apiInstanceDetails == null) {
837                         apiInstanceDetails = new org.uddi.api_v3.InstanceDetails();
838                 }
839 
840                 //InstanceParms
841                 apiInstanceDetails.setInstanceParms(modelTModelInstInfo.getInstanceParms());
842                 //Descriptions
843                 List<org.apache.juddi.model.InstanceDetailsDescr> modelInstDetailsDescrList = modelTModelInstInfo.getInstanceDetailsDescrs();
844                 for (org.apache.juddi.model.InstanceDetailsDescr modelInstDetailDescr : modelInstDetailsDescrList) {
845                         org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
846                         apiDesc.setLang(modelInstDetailDescr.getLangCode());
847                         apiDesc.setValue(modelInstDetailDescr.getDescr());
848                         apiInstanceDetails.getDescription().add(apiDesc);
849                 }
850                 //OverviewDoc
851                 mapOverviewDocs(modelTModelInstInfo.getOverviewDocs(), apiInstanceDetails, null);
852 
853                 apiTModelInstInfo.setInstanceDetails(apiInstanceDetails);
854         }
855 
856         public static void mapOverviewDocs(List<org.apache.juddi.model.OverviewDoc> modelOverviewDocs,
857              org.uddi.api_v3.InstanceDetails apiInstanceDetails,
858              org.uddi.api_v3.TModel apiTModel) {
859                 for (OverviewDoc modelOverviewDoc : modelOverviewDocs) {
860                         org.uddi.api_v3.OverviewDoc apiOverviewDoc = new org.uddi.api_v3.OverviewDoc();
861 
862                         //Descriptions
863                         List<org.apache.juddi.model.OverviewDocDescr> overviewDocDescrList = modelOverviewDoc.getOverviewDocDescrs();
864                         for (org.apache.juddi.model.OverviewDocDescr overviewDocDescr : overviewDocDescrList) {
865                                 org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
866                                 apiDesc.setLang(overviewDocDescr.getLangCode());
867                                 apiDesc.setValue(overviewDocDescr.getDescr());
868                                 apiOverviewDoc.getDescription().add(apiDesc);
869                         }
870                         //OverviewURL
871                         org.uddi.api_v3.OverviewURL apiOverviewURL = new org.uddi.api_v3.OverviewURL();
872                         apiOverviewURL.setUseType(modelOverviewDoc.getOverviewUrlUseType());
873                         apiOverviewURL.setValue(modelOverviewDoc.getOverviewUrl());
874                         apiOverviewDoc.setOverviewURL(apiOverviewURL);
875                         //Set the entity on the apiOverviewDoc
876                         if (apiInstanceDetails != null) {
877                                 apiInstanceDetails.getOverviewDoc().add(apiOverviewDoc);
878                         } else {
879                                 apiTModel.getOverviewDoc().add(apiOverviewDoc);
880                         }
881                 }
882         }
883 
884         public static void mapTModel(org.apache.juddi.model.Tmodel modelTModel,
885              org.uddi.api_v3.TModel apiTModel)
886              throws DispositionReportFaultMessage {
887 
888                 apiTModel.setTModelKey(modelTModel.getEntityKey());
889                 org.uddi.api_v3.Name apiName = new org.uddi.api_v3.Name();
890                 apiName.setValue(modelTModel.getName());
891                 apiName.setLang(modelTModel.getLangCode());
892                 apiTModel.setName(apiName);
893                 apiTModel.setDeleted(modelTModel.getDeleted());
894 
895                 mapTModelDescriptions(modelTModel.getTmodelDescrs(), apiTModel.getDescription());
896 
897                 mapTModelIdentifiers(modelTModel.getTmodelIdentifiers(), apiTModel.getIdentifierBag(), apiTModel);
898                 apiTModel.setCategoryBag(mapCategoryBag(modelTModel.getCategoryBag(), apiTModel.getCategoryBag()));
899 
900                 mapOverviewDocs(modelTModel.getOverviewDocs(), null, apiTModel);
901                 mapSignature(modelTModel.getSignatures(), apiTModel.getSignature());
902         }
903 
904         public static void mapTModelDescriptions(List<org.apache.juddi.model.TmodelDescr> modelDescList,
905              List<org.uddi.api_v3.Description> apiDescList)
906              throws DispositionReportFaultMessage {
907                 apiDescList.clear();
908 
909                 for (org.apache.juddi.model.TmodelDescr modelDesc : modelDescList) {
910                         org.uddi.api_v3.Description apiDesc = new org.uddi.api_v3.Description();
911                         apiDesc.setLang(modelDesc.getLangCode());
912                         apiDesc.setValue(modelDesc.getDescr());
913                         apiDescList.add(apiDesc);
914                 }
915         }
916 
917         public static void mapTModelIdentifiers(List<org.apache.juddi.model.TmodelIdentifier> modelIdentifierList,
918              org.uddi.api_v3.IdentifierBag apiIdentifierBag,
919              org.uddi.api_v3.TModel apiTModel)
920              throws DispositionReportFaultMessage {
921                 if (modelIdentifierList == null || modelIdentifierList.size() == 0) {
922                         return;
923                 }
924 
925                 if (apiIdentifierBag == null) {
926                         apiIdentifierBag = new org.uddi.api_v3.IdentifierBag();
927                 }
928 
929                 List<org.uddi.api_v3.KeyedReference> apiKeyedRefList = apiIdentifierBag.getKeyedReference();
930                 apiKeyedRefList.clear();
931 
932                 for (org.apache.juddi.model.TmodelIdentifier modelIdentifier : modelIdentifierList) {
933                         org.uddi.api_v3.KeyedReference apiKeyedRef = new org.uddi.api_v3.KeyedReference();
934                         apiKeyedRef.setTModelKey(modelIdentifier.getTmodelKeyRef());
935                         apiKeyedRef.setKeyName(modelIdentifier.getKeyName());
936                         apiKeyedRef.setKeyValue(modelIdentifier.getKeyValue());
937                         apiKeyedRefList.add(apiKeyedRef);
938                 }
939                 apiTModel.setIdentifierBag(apiIdentifierBag);
940         }
941 
942         public static void mapBusinessInfo(org.apache.juddi.model.BusinessEntity modelBusinessEntity,
943              org.uddi.api_v3.BusinessInfo apiBusinessInfo)
944              throws DispositionReportFaultMessage {
945 
946                 apiBusinessInfo.setBusinessKey(modelBusinessEntity.getEntityKey());
947 
948                 mapBusinessNames(modelBusinessEntity.getBusinessNames(), apiBusinessInfo.getName());
949                 mapBusinessDescriptions(modelBusinessEntity.getBusinessDescrs(), apiBusinessInfo.getDescription());
950 
951                 mapServiceInfos(modelBusinessEntity.getBusinessServices(), apiBusinessInfo.getServiceInfos(), apiBusinessInfo);
952 
953         }
954 
955         public static void mapServiceInfos(List<org.apache.juddi.model.BusinessService> modelBusinessServiceList,
956              org.uddi.api_v3.ServiceInfos apiServiceInfos,
957              org.uddi.api_v3.BusinessInfo apiBusinessInfo)
958              throws DispositionReportFaultMessage {
959                 if (modelBusinessServiceList.size() == 0) {
960                         return;
961                 }
962                 if (apiServiceInfos == null) {
963                         apiServiceInfos = new org.uddi.api_v3.ServiceInfos();
964                 }
965 
966                 List<org.uddi.api_v3.ServiceInfo> apiServiceInfoList = apiServiceInfos.getServiceInfo();
967                 apiServiceInfoList.clear();
968 
969                 for (org.apache.juddi.model.BusinessService modelBusinessService : modelBusinessServiceList) {
970                         org.uddi.api_v3.ServiceInfo apiServiceInfo = new org.uddi.api_v3.ServiceInfo();
971 
972                         mapServiceInfo(modelBusinessService, apiServiceInfo);
973 
974                         apiServiceInfos.getServiceInfo().add(apiServiceInfo);
975                 }
976                 apiBusinessInfo.setServiceInfos(apiServiceInfos);
977         }
978 
979         public static void mapServiceInfo(org.apache.juddi.model.BusinessService modelBusinessService,
980              org.uddi.api_v3.ServiceInfo apiServiceInfo)
981              throws DispositionReportFaultMessage {
982 
983                 apiServiceInfo.setBusinessKey(modelBusinessService.getBusinessEntity().getEntityKey());
984                 apiServiceInfo.setServiceKey(modelBusinessService.getEntityKey());
985 
986                 mapServiceNames(modelBusinessService.getServiceNames(), apiServiceInfo.getName());
987         }
988 
989         public static void mapTModelInfo(org.apache.juddi.model.Tmodel modelTModel,
990              org.uddi.api_v3.TModelInfo apiTModelInfo)
991              throws DispositionReportFaultMessage {
992 
993                 apiTModelInfo.setTModelKey(modelTModel.getEntityKey());
994                 org.uddi.api_v3.Name apiName = new org.uddi.api_v3.Name();
995                 apiName.setValue(modelTModel.getName());
996                 apiName.setLang(modelTModel.getLangCode());
997                 apiTModelInfo.setName(apiName);
998 
999                 mapTModelDescriptions(modelTModel.getTmodelDescrs(), apiTModelInfo.getDescription());
1000 
1001         }
1002 
1003         public static void mapAuthToken(org.apache.juddi.model.AuthToken modelAuthToken,
1004              org.uddi.api_v3.AuthToken apiAuthToken)
1005              throws DispositionReportFaultMessage {
1006                 apiAuthToken.setAuthInfo(modelAuthToken.getAuthToken());
1007 
1008         }
1009 
1010         public static void mapPublisherAssertion(org.apache.juddi.model.PublisherAssertion modelPublisherAssertion,
1011              org.uddi.api_v3.PublisherAssertion apiPublisherAssertion)
1012              throws DispositionReportFaultMessage {
1013 
1014                 apiPublisherAssertion.setFromKey(modelPublisherAssertion.getId().getFromKey());
1015                 apiPublisherAssertion.setToKey(modelPublisherAssertion.getId().getToKey());
1016 
1017                 org.uddi.api_v3.KeyedReference keyedRef = new org.uddi.api_v3.KeyedReference();
1018                 keyedRef.setTModelKey(modelPublisherAssertion.getTmodelKey());
1019                 keyedRef.setKeyName(modelPublisherAssertion.getKeyName());
1020                 keyedRef.setKeyValue(modelPublisherAssertion.getKeyValue());
1021 
1022                 if (modelPublisherAssertion.getSignatures()!=null &&
1023                         !modelPublisherAssertion.getSignatures().isEmpty())
1024                 {
1025                         mapSignature(modelPublisherAssertion.getSignatures(), apiPublisherAssertion.getSignature());
1026                 }
1027                 apiPublisherAssertion.setKeyedReference(keyedRef);
1028                
1029         }
1030 
1031         public static void mapAssertionStatusItem(org.apache.juddi.model.PublisherAssertion modelPublisherAssertion,
1032              org.uddi.api_v3.AssertionStatusItem apiAssertionStatusItem,
1033              List<?> businessKeys)
1034              throws DispositionReportFaultMessage {
1035 
1036                 apiAssertionStatusItem.setFromKey(modelPublisherAssertion.getId().getFromKey());
1037                 apiAssertionStatusItem.setToKey(modelPublisherAssertion.getId().getToKey());
1038 
1039                 org.uddi.api_v3.KeyedReference keyedRef = new org.uddi.api_v3.KeyedReference();
1040                 keyedRef.setTModelKey(modelPublisherAssertion.getTmodelKey());
1041                 keyedRef.setKeyName(modelPublisherAssertion.getKeyName());
1042                 keyedRef.setKeyValue(modelPublisherAssertion.getKeyValue());
1043 
1044                 apiAssertionStatusItem.setKeyedReference(keyedRef);
1045 
1046                 if ("true".equalsIgnoreCase(modelPublisherAssertion.getFromCheck())
1047                      && "true".equalsIgnoreCase(modelPublisherAssertion.getToCheck())) {
1048                         apiAssertionStatusItem.setCompletionStatus(CompletionStatus.STATUS_COMPLETE);
1049                 } else if (!"true".equalsIgnoreCase(modelPublisherAssertion.getFromCheck())
1050                      && "true".equalsIgnoreCase(modelPublisherAssertion.getToCheck())) {
1051                         apiAssertionStatusItem.setCompletionStatus(CompletionStatus.STATUS_FROM_KEY_INCOMPLETE);
1052                 } else if ("true".equalsIgnoreCase(modelPublisherAssertion.getFromCheck())
1053                      && !"true".equalsIgnoreCase(modelPublisherAssertion.getToCheck())) {
1054                         apiAssertionStatusItem.setCompletionStatus(CompletionStatus.STATUS_TO_KEY_INCOMPLETE);
1055                 } else if (!"true".equalsIgnoreCase(modelPublisherAssertion.getFromCheck())
1056                      && !"true".equalsIgnoreCase(modelPublisherAssertion.getToCheck())) {
1057                         apiAssertionStatusItem.setCompletionStatus(CompletionStatus.STATUS_BOTH_INCOMPLETE);
1058                 }
1059 
1060                 org.uddi.api_v3.KeysOwned keysOwned = new org.uddi.api_v3.KeysOwned();
1061 
1062                 //converting resultList to simple List
1063                 List<String> businessKeyList = new ArrayList<String>();
1064                 for (Object businessKey : businessKeys) {
1065                         businessKeyList.add(String.valueOf(businessKey));
1066                 }
1067                 Collections.sort(businessKeyList);
1068                 if (Collections.binarySearch(businessKeyList, modelPublisherAssertion.getBusinessEntityByFromKey().getEntityKey()) >= 0) {
1069                         keysOwned.setFromKey(modelPublisherAssertion.getBusinessEntityByFromKey().getEntityKey());
1070                 }
1071 
1072                 if (Collections.binarySearch(businessKeyList, modelPublisherAssertion.getBusinessEntityByToKey().getEntityKey()) >= 0) {
1073                         keysOwned.setToKey(modelPublisherAssertion.getBusinessEntityByToKey().getEntityKey());
1074                 }
1075                 if (keysOwned.getFromKey() == null && keysOwned.getToKey() == null) {
1076                         throw new FatalErrorException(new ErrorMessage("errors.invalidKey.KeysOwned"));
1077                 }
1078                 apiAssertionStatusItem.setKeysOwned(keysOwned);
1079         }
1080 
1081         public static void mapRelatedBusinessInfo(org.apache.juddi.model.PublisherAssertion modelPublisherAssertion,
1082              org.apache.juddi.model.BusinessEntity modelRelatedBusiness,
1083              org.uddi.api_v3.Direction direction,
1084              org.uddi.api_v3.RelatedBusinessInfo apiRelatedBusinessInfo)
1085              throws DispositionReportFaultMessage {
1086 
1087                 apiRelatedBusinessInfo.setBusinessKey(modelRelatedBusiness.getEntityKey());
1088 
1089                 mapBusinessNames(modelRelatedBusiness.getBusinessNames(), apiRelatedBusinessInfo.getName());
1090                 mapBusinessDescriptions(modelRelatedBusiness.getBusinessDescrs(), apiRelatedBusinessInfo.getDescription());
1091 
1092                 org.uddi.api_v3.SharedRelationships sharedRelationships = new org.uddi.api_v3.SharedRelationships();
1093                 sharedRelationships.setDirection(direction);
1094 
1095                 org.uddi.api_v3.KeyedReference keyedRef = new org.uddi.api_v3.KeyedReference();
1096                 keyedRef.setTModelKey(modelPublisherAssertion.getTmodelKey());
1097                 keyedRef.setKeyName(modelPublisherAssertion.getKeyName());
1098                 keyedRef.setKeyValue(modelPublisherAssertion.getKeyValue());
1099                 sharedRelationships.getKeyedReference().add(keyedRef);
1100 
1101                 apiRelatedBusinessInfo.getSharedRelationships().add(sharedRelationships);
1102         }
1103 
1104         public static void mapOperationalInfo(UddiEntity modelUddiEntity,
1105              OperationalInfo apiOperationalInfo)
1106              throws DispositionReportFaultMessage {
1107 
1108                 apiOperationalInfo.setCreated(TypeConvertor.convertDateToXMLGregorianCalendar(modelUddiEntity.getCreated()));
1109                 apiOperationalInfo.setModified(TypeConvertor.convertDateToXMLGregorianCalendar(modelUddiEntity.getModified()));
1110                 apiOperationalInfo.setModifiedIncludingChildren(TypeConvertor.convertDateToXMLGregorianCalendar(modelUddiEntity.getModifiedIncludingChildren()));
1111                 apiOperationalInfo.setNodeID(modelUddiEntity.getNodeId());
1112                 apiOperationalInfo.setAuthorizedName(modelUddiEntity.getAuthorizedName());
1113                 apiOperationalInfo.setEntityKey(modelUddiEntity.getEntityKey());
1114         }
1115 
1116         public static void mapSubscription(org.apache.juddi.model.Subscription modelSubscription,
1117              org.uddi.sub_v3.Subscription apiSubscription)
1118              throws DispositionReportFaultMessage {
1119 
1120                 apiSubscription.setSubscriptionKey(modelSubscription.getSubscriptionKey());
1121                 apiSubscription.setBrief(modelSubscription.isBrief());
1122                 apiSubscription.setExpiresAfter(TypeConvertor.convertDateToXMLGregorianCalendar(modelSubscription.getExpiresAfter()));
1123                 apiSubscription.setBindingKey(modelSubscription.getBindingKey());
1124                 apiSubscription.setMaxEntities(modelSubscription.getMaxEntities());
1125                 apiSubscription.setNotificationInterval(TypeConvertor.convertStringToDuration(modelSubscription.getNotificationInterval()));
1126 
1127                 try {
1128                         SubscriptionFilter existingFilter = (SubscriptionFilter) JAXBMarshaller.unmarshallFromString(modelSubscription.getSubscriptionFilter(), JAXBMarshaller.PACKAGE_SUBSCRIPTION);
1129                         apiSubscription.setSubscriptionFilter(existingFilter);
1130                 } catch (JAXBException e) {
1131                         logger.error("JAXB Exception while marshalling subscription filter", e);
1132                         throw new FatalErrorException(new ErrorMessage("errors.Unspecified"));
1133                 }
1134         }
1135 
1136         public static void mapClientSubscriptionInfo(org.apache.juddi.model.ClientSubscriptionInfo modelClientSubscriptionInfo,
1137              org.apache.juddi.api_v3.ClientSubscriptionInfo apiClientSubscriptionInfo, EntityManager em)
1138              throws DispositionReportFaultMessage {
1139 
1140                 apiClientSubscriptionInfo.setSubscriptionKey(modelClientSubscriptionInfo.getSubscriptionKey());
1141                 GregorianCalendar gcal = new GregorianCalendar();
1142                 gcal.setTimeInMillis(modelClientSubscriptionInfo.getLastNotified().getTime());
1143                 try {
1144                         apiClientSubscriptionInfo.setLastModified(DatatypeFactory.newInstance().newXMLGregorianCalendar(gcal));
1145                 } catch (DatatypeConfigurationException ex) {
1146                         logger.warn("unable to create DatatypeFactory", ex);
1147                 }
1148 
1149                 if (modelClientSubscriptionInfo.getFromClerk() != null) {
1150                         org.apache.juddi.api_v3.Clerk apiFromClerk = new org.apache.juddi.api_v3.Clerk();
1151                         mapClerk(modelClientSubscriptionInfo.getFromClerk(), apiFromClerk,em);
1152                         apiClientSubscriptionInfo.setFromClerk(apiFromClerk);
1153                 }
1154                 if (modelClientSubscriptionInfo.getToClerk() != null) {
1155                         org.apache.juddi.api_v3.Clerk apiToClerk = new org.apache.juddi.api_v3.Clerk();
1156                         mapClerk(modelClientSubscriptionInfo.getToClerk(), apiToClerk,em);
1157                         apiClientSubscriptionInfo.setToClerk(apiToClerk);
1158                 }
1159         }
1160 
1161         public static void mapClerk(org.apache.juddi.model.Clerk modelClerk,
1162              org.apache.juddi.api_v3.Clerk apiClerk,EntityManager em)
1163              throws DispositionReportFaultMessage {
1164 
1165                 apiClerk.setName(modelClerk.getClerkName());
1166                 apiClerk.setPassword(modelClerk.getCred());
1167                 apiClerk.setPublisher(modelClerk.getPublisherId());
1168                 if (modelClerk.getNode() != null) {
1169                         org.apache.juddi.api_v3.Node apiNode = new org.apache.juddi.api_v3.Node();
1170                         mapNode(
1171                                 em.find(org.apache.juddi.model.Node.class, modelClerk.getNode()) 
1172                                , apiNode);
1173                         apiClerk.setNode(apiNode);
1174                 }
1175         }
1176 
1177         public static void mapNode(org.apache.juddi.model.Node modelNode,
1178              org.apache.juddi.api_v3.Node apiNode)
1179              throws DispositionReportFaultMessage {
1180 
1181                 apiNode.setCustodyTransferUrl(modelNode.getCustodyTransferUrl());
1182                 apiNode.setFactoryInitial(modelNode.getFactoryInitial());
1183                 apiNode.setFactoryNamingProvider(modelNode.getFactoryNamingProvider());
1184                 apiNode.setFactoryURLPkgs(modelNode.getFactoryURLPkgs());
1185                 apiNode.setInquiryUrl(modelNode.getInquiryUrl());
1186                 apiNode.setJuddiApiUrl(modelNode.getJuddiApiUrl());
1187                 apiNode.setName(modelNode.getName());
1188                 apiNode.setClientName(modelNode.getClientName());
1189                 apiNode.setProxyTransport(modelNode.getProxyTransport());
1190                 apiNode.setPublishUrl(modelNode.getPublishUrl());
1191                 apiNode.setSecurityUrl(modelNode.getSecurityUrl());
1192                 apiNode.setSubscriptionUrl(modelNode.getSubscriptionUrl());
1193                 apiNode.setSubscriptionListenerUrl(modelNode.getSubscriptionListenerUrl());
1194                 apiNode.setReplicationUrl(modelNode.getReplicationUrl());
1195         }
1196 
1197         private static Object convertDataToTransformContent(String type, byte[] xformBytes) throws RuntimeException {
1198                 Object transformObject;
1199                 if (type.equals(String.class.getSimpleName())) {
1200                         try {
1201                                 transformObject = new String(xformBytes, "UTF-8");
1202                         } catch (Exception e) {
1203                                 throw new RuntimeException("Error decoding string due to: " + e.getMessage(), e);
1204                         }
1205                 } else if (type.equals(byte[].class.getSimpleName())) {
1206                         transformObject = xformBytes;
1207                 } else if (type.equals(Element.class.getCanonicalName())) {
1208                         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
1209                          try {
1210                                 dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
1211                                 dbf.setNamespaceAware(true);
1212                                 dbf.setXIncludeAware(true);
1213 
1214                                 DocumentBuilder db = dbf.newDocumentBuilder();
1215                                 Document doc = db.parse(new ByteArrayInputStream(xformBytes));
1216                                 transformObject = doc.getDocumentElement();
1217                         } catch (Exception e) {
1218                                 throw new RuntimeException("Failed to parse element due to: " + e.getMessage(), e);
1219                         }
1220                 } else {
1221                         throw new RuntimeException("Unrecognized type: " + type);
1222                 }
1223                 return transformObject;
1224         }
1225 
1226         public static void mapReplicationConfiguration(ReplicationConfiguration find, org.uddi.repl_v3.ReplicationConfiguration item) throws DispositionReportFaultMessage {
1227                 item.setMaximumTimeToGetChanges(find.getMaximumTimeToGetChanges());
1228                 item.setMaximumTimeToSyncRegistry(find.getMaximumTimeToSyncRegistry());
1229                 item.setSerialNumber(find.getSerialNumber());
1230                 
1231                 List<SignatureType> sigs = new ArrayList<SignatureType>();
1232                 mapSignature(find.getSignatures(), sigs);
1233                 item.getSignature().addAll(sigs);
1234                 mapOperator(find.getOperator(), item.getOperator());
1235 
1236                 List<org.apache.juddi.model.Contact> modelContactList = new ArrayList<org.apache.juddi.model.Contact>();
1237                 org.uddi.api_v3.Contacts cs = new Contacts();
1238 
1239                 mapContacts(modelContactList, cs, new BusinessEntity());
1240                 item.setRegistryContact(new org.uddi.repl_v3.ReplicationConfiguration.RegistryContact());
1241                 if (!cs.getContact().isEmpty()) {
1242                         
1243                         item.getRegistryContact().setContact(cs.getContact().get(0));
1244                 }
1245                 else
1246                 {
1247                         item.getRegistryContact().setContact(new Contact());
1248                         item.getRegistryContact().getContact().getPersonName().add(new PersonName("unknown", null));
1249                 }
1250                 item.setTimeOfConfigurationUpdate(find.getTimeOfConfigurationUpdate());
1251                 CommunicationGraph xcom = new CommunicationGraph();
1252 
1253                 mapCommunicationGraph(find, xcom);
1254                 item.setCommunicationGraph(xcom);
1255                 //(List<org.apache.juddi.model.Contact> modelContactList, 
1256                 //org.uddi.api_v3.Contacts apiContacts,
1257                 //org.uddi.api_v3.BusinessEntity apiBusinessEntity) 
1258         }
1259 
1260         private static void mapOperator(List<org.apache.juddi.model.Operator> model, List<Operator> api) throws DispositionReportFaultMessage {
1261                 for (int i = 0; i < model.size(); i++) {
1262                         Operator op = new Operator();
1263                         op.setOperatorNodeID(model.get(i).getOperatorNodeID());
1264                         op.setSoapReplicationURL(model.get(i).getSoapReplicationURL());
1265                         switch (model.get(i).getOperatorStatus()) {
1266                                 case NEW:
1267                                         op.setOperatorStatus(OperatorStatusType.NEW);
1268                                         break;
1269                                 case NORMAL:
1270                                         op.setOperatorStatus(OperatorStatusType.NORMAL);
1271                                         break;
1272                                 case RESIGNED:
1273                                         op.setOperatorStatus(OperatorStatusType.RESIGNED);
1274                                         break;
1275                         }
1276                         Contacts c = new Contacts();
1277                         mapContacts(model.get(i).getContact(), c, new BusinessEntity());
1278                         op.getContact().addAll(c.getContact());
1279 
1280                         if (model.get(i).getKeyInfo() != null) {
1281                                 for (int x = 0; x < model.get(i).getKeyInfo().size(); x++) {
1282                                         KeyInfoType apiKeyInfo = new KeyInfoType();
1283                                         KeyInfo modelKeyInfo = model.get(i).getKeyInfo().get(x);
1284                                         apiKeyInfo.setId(modelKeyInfo.getXmlID());
1285                                         List<KeyDataValue> modelKeyDataValueList = modelKeyInfo.getKeyDataValue();
1286                                         List<Object> apiX509KeyInfoList = apiKeyInfo.getContent();
1287                                         mapModelKeyDataValue(modelKeyDataValueList, apiX509KeyInfoList);
1288                                         op.getKeyInfo().add(apiKeyInfo);
1289                                 }
1290                         }
1291                         api.add(op);
1292                 }
1293 
1294         }
1295 
1296         private static void mapCommunicationGraph(org.apache.juddi.model.ReplicationConfiguration model,
1297              CommunicationGraph api) {
1298 
1299                 mapEdge(model.getEdge(), api.getEdge());
1300                 mapControlMessages(model.getControlMessage(), api.getControlledMessage());
1301                 mapEdgeNodes(model.getNode(), api.getNode());
1302 
1303         }
1304 
1305         private static void mapEdge(List<Edge> model, List<CommunicationGraph.Edge> api) {
1306                 Iterator<Edge> it = model.iterator();
1307                 while (it.hasNext()) {
1308                         Edge modelEdge = it.next();
1309 
1310                         CommunicationGraph.Edge apiEdge = new CommunicationGraph.Edge();
1311                         apiEdge.setMessageReceiver(modelEdge.getMessageReceiver());
1312                         apiEdge.setMessageSender(modelEdge.getMessageSender());
1313 
1314                         Iterator<ControlMessage> it2 = modelEdge.getMessages().iterator();
1315                         while (it2.hasNext()) {
1316                                 apiEdge.getMessage().add(it2.next().getMessage());
1317                         }
1318                         Iterator<EdgeReceiverAlternate> it3 = modelEdge.getMessageReceiverAlternate().iterator();
1319                         while (it3.hasNext()) {
1320                                 apiEdge.getMessageReceiverAlternate().add(it3.next().getReceiverAlternate());
1321                         }
1322 
1323                         api.add(apiEdge);
1324 
1325                 }
1326         }
1327 
1328         private static void mapControlMessages(List<ControlMessage> model, List<String> api) {
1329                 Iterator<ControlMessage> it = model.iterator();
1330                 while (it.hasNext()) {
1331                         api.add(it.next().getMessage());
1332                 }
1333         }
1334 
1335         private static void mapEdgeNodes(List<ReplicationConfigurationNode> model, List<String> api) {
1336                 Iterator<ReplicationConfigurationNode> it = model.iterator();
1337                 while (it.hasNext()) {
1338                         api.add(it.next().getNodeName());
1339                 }
1340         }
1341 
1342         public static ChangeRecord mapChangeRecord(org.apache.juddi.model.ChangeRecord cr) {
1343                 if (cr == null) {
1344                         return null;
1345                 }
1346                 ChangeRecord ret = null;
1347 
1348                 StringReader sr = null;
1349                 try {
1350                         sr = new StringReader(new String(cr.getContents(), "UTF8"));
1351                 } catch (UnsupportedEncodingException ex) {
1352                         Logger.getLogger(MappingModelToApi.class.getName()).log(Level.SEVERE, null, ex);
1353                 }
1354                 ret = (ChangeRecord) XmlUtils.unmarshal(sr, ChangeRecord.class);
1355                 //secret sauce here, if this is -1, that means that the record originated at this node and needs to be populated with the databases record id
1356                 if (cr.getOriginatingUSN() == null || cr.getOriginatingUSN() == -1L) {
1357                         ret.setChangeID(new ChangeRecordIDType(cr.getNodeID(), cr.getId()));
1358                 } else {
1359                         ret.setChangeID(new ChangeRecordIDType(cr.getNodeID(), cr.getOriginatingUSN()));
1360                 }
1361                 return ret;
1362 
1363         }
1364 }