View Javadoc
1   /*
2    * Copyright 2014 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.v3.client.transport.wrapper;
17  
18  import java.rmi.RemoteException;
19  import java.util.List;
20  import java.util.Map;
21  import javax.xml.ws.Binding;
22  import javax.xml.ws.BindingProvider;
23  import javax.xml.ws.EndpointReference;
24  import javax.xml.ws.Holder;
25  import javax.xml.ws.soap.SOAPFaultException;
26  import org.apache.juddi.v3.client.UDDIServiceV2;
27  import org.apache.juddi.v3.client.mapping.MapUDDIv2Tov3;
28  import org.apache.juddi.v3.client.mapping.MapUDDIv3Tov2;
29  import org.uddi.api_v2.AssertionStatusReport;
30  import org.uddi.api_v2.PublisherAssertions;
31  import org.uddi.api_v2.SetPublisherAssertions;
32  import org.uddi.api_v3.AddPublisherAssertions;
33  import org.uddi.api_v3.AssertionStatusItem;
34  import org.uddi.api_v3.BindingDetail;
35  import org.uddi.api_v3.BusinessDetail;
36  import org.uddi.api_v3.CompletionStatus;
37  import org.uddi.api_v3.DeleteBinding;
38  import org.uddi.api_v3.DeleteBusiness;
39  import org.uddi.api_v3.DeletePublisherAssertions;
40  import org.uddi.api_v3.DeleteService;
41  import org.uddi.api_v3.DeleteTModel;
42  import org.uddi.api_v3.GetRegisteredInfo;
43  import org.uddi.api_v3.PublisherAssertion;
44  import org.uddi.api_v3.RegisteredInfo;
45  import org.uddi.api_v3.SaveBinding;
46  import org.uddi.api_v3.SaveBusiness;
47  import org.uddi.api_v3.SaveService;
48  import org.uddi.api_v3.SaveTModel;
49  import org.uddi.api_v3.ServiceDetail;
50  import org.uddi.api_v3.TModelDetail;
51  import org.uddi.v2_service.DispositionReport;
52  import org.uddi.v2_service.Publish;
53  import org.uddi.v3_service.DispositionReportFaultMessage;
54  import org.uddi.v3_service.UDDIPublicationPortType;
55  
56  /**
57   * This class provides a wrapper to enable UDDIv3 clients to talk to UDDIv2
58   * servers via JAXWS Transport. It handles all translations for Publish 
59   * service methods.
60   *
61   * @author <a href="alexoree@apache.org">Alex O'Ree</a>
62   * @since 3.2
63   */
64  public class Publish3to2 implements UDDIPublicationPortType, BindingProvider {
65  
66     Publish publishService = null;
67  
68     public Publish3to2() {
69  
70        UDDIServiceV2 service = new UDDIServiceV2();
71        publishService = service.getPublish();
72  
73     }
74     
75     public Publish getUDDIv2PublishWebServiceClient(){
76          return publishService;
77     }
78  
79     @Override
80     public void addPublisherAssertions(AddPublisherAssertions body) throws DispositionReportFaultMessage, RemoteException {
81        try {
82           publishService.addPublisherAssertions(MapUDDIv3Tov2.MapAddPublisherAssertions(body));
83        } catch (DispositionReport ex) {
84           throw MapUDDIv2Tov3.MapException(ex);
85        } catch (SOAPFaultException ex) {
86           throw MapUDDIv2Tov3.MapException(ex);
87        }
88     }
89  
90     @Override
91     public void deleteBinding(DeleteBinding body) throws DispositionReportFaultMessage, RemoteException {
92        try {
93           publishService.deleteBinding(MapUDDIv3Tov2.MapDeleteBinding(body));
94        } catch (DispositionReport ex) {
95           throw MapUDDIv2Tov3.MapException(ex);
96        } catch (SOAPFaultException ex) {
97           throw MapUDDIv2Tov3.MapException(ex);
98        }
99     }
100 
101    @Override
102    public void deleteBusiness(DeleteBusiness body) throws DispositionReportFaultMessage, RemoteException {
103       try {
104          publishService.deleteBusiness(MapUDDIv3Tov2.MapDeleteBusiness(body));
105       } catch (DispositionReport ex) {
106          throw MapUDDIv2Tov3.MapException(ex);
107       } catch (SOAPFaultException ex) {
108          throw MapUDDIv2Tov3.MapException(ex);
109       }
110    }
111 
112    @Override
113    public void deletePublisherAssertions(DeletePublisherAssertions body) throws DispositionReportFaultMessage, RemoteException {
114       try {
115          publishService.deletePublisherAssertions(MapUDDIv3Tov2.MapDeletePublisherAssertions(body));
116       } catch (DispositionReport ex) {
117          throw MapUDDIv2Tov3.MapException(ex);
118       } catch (SOAPFaultException ex) {
119          throw MapUDDIv2Tov3.MapException(ex);
120       }
121    }
122 
123    @Override
124    public void deleteService(DeleteService body) throws DispositionReportFaultMessage, RemoteException {
125       try {
126          publishService.deleteService(MapUDDIv3Tov2.MapDeleteService(body));
127       } catch (DispositionReport ex) {
128          throw MapUDDIv2Tov3.MapException(ex);
129       } catch (SOAPFaultException ex) {
130          throw MapUDDIv2Tov3.MapException(ex);
131       }
132    }
133 
134    @Override
135    public void deleteTModel(DeleteTModel body) throws DispositionReportFaultMessage, RemoteException {
136       try {
137          publishService.deleteTModel(MapUDDIv3Tov2.MapDeleteTModel(body));
138       } catch (DispositionReport ex) {
139          throw MapUDDIv2Tov3.MapException(ex);
140       } catch (SOAPFaultException ex) {
141          throw MapUDDIv2Tov3.MapException(ex);
142       }
143    }
144 
145    @Override
146    public List<AssertionStatusItem> getAssertionStatusReport(String authInfo, CompletionStatus completionStatus) throws DispositionReportFaultMessage, RemoteException {
147       try {
148          AssertionStatusReport assertionStatusReport = publishService.getAssertionStatusReport(MapUDDIv3Tov2.MapGetAssertionStatusReport(authInfo, completionStatus));
149          return MapUDDIv2Tov3.MapAssertionStatusItems(assertionStatusReport);
150       } catch (DispositionReport ex) {
151          throw MapUDDIv2Tov3.MapException(ex);
152       } catch (SOAPFaultException ex) {
153          throw MapUDDIv2Tov3.MapException(ex);
154       }
155    }
156 
157    @Override
158    public List<PublisherAssertion> getPublisherAssertions(String authInfo) throws DispositionReportFaultMessage, RemoteException {
159       try {
160          return MapUDDIv2Tov3.MapListPublisherAssertion(publishService.getPublisherAssertions(MapUDDIv3Tov2.MapGetPublisherAssertions(authInfo)));
161       } catch (DispositionReport ex) {
162          throw MapUDDIv2Tov3.MapException(ex);
163       } catch (SOAPFaultException ex) {
164          throw MapUDDIv2Tov3.MapException(ex);
165       }
166    }
167 
168    @Override
169    public RegisteredInfo getRegisteredInfo(GetRegisteredInfo body) throws DispositionReportFaultMessage, RemoteException {
170       try {
171          return MapUDDIv2Tov3.MapListRegisteredInfo(publishService.getRegisteredInfo(MapUDDIv3Tov2.MapGetRegisteredInfo(body)));
172       } catch (DispositionReport ex) {
173          throw MapUDDIv2Tov3.MapException(ex);
174       } catch (SOAPFaultException ex) {
175          throw MapUDDIv2Tov3.MapException(ex);
176       }
177 
178    }
179 
180    @Override
181    public BindingDetail saveBinding(SaveBinding body) throws DispositionReportFaultMessage, RemoteException {
182       try {
183          return MapUDDIv2Tov3.MapBindingDetail(publishService.saveBinding(MapUDDIv3Tov2.MapSaveBinding(body)));
184       } catch (DispositionReport ex) {
185          throw MapUDDIv2Tov3.MapException(ex);
186       } catch (SOAPFaultException ex) {
187          throw MapUDDIv2Tov3.MapException(ex);
188       }
189    }
190 
191    @Override
192    public BusinessDetail saveBusiness(SaveBusiness body) throws DispositionReportFaultMessage, RemoteException {
193       try {
194          return MapUDDIv2Tov3.MapBusinessDetail(publishService.saveBusiness(MapUDDIv3Tov2.MapSaveBusiness(body)));
195       } catch (DispositionReport ex) {
196          throw MapUDDIv2Tov3.MapException(ex);
197       } catch (SOAPFaultException ex) {
198          throw MapUDDIv2Tov3.MapException(ex);
199       }
200    }
201 
202    @Override
203    public ServiceDetail saveService(SaveService body) throws DispositionReportFaultMessage, RemoteException {
204       try {
205          return MapUDDIv2Tov3.MapServiceDetail(publishService.saveService(MapUDDIv3Tov2.MapSaveService(body)));
206       } catch (DispositionReport ex) {
207          throw MapUDDIv2Tov3.MapException(ex);
208       } catch (SOAPFaultException ex) {
209          throw MapUDDIv2Tov3.MapException(ex);
210       }
211    }
212 
213    @Override
214    public TModelDetail saveTModel(SaveTModel body) throws DispositionReportFaultMessage, RemoteException {
215       try {
216          return MapUDDIv2Tov3.MapTModelDetail(publishService.saveTModel(MapUDDIv3Tov2.MapSaveTModel(body)));
217       } catch (DispositionReport ex) {
218          throw MapUDDIv2Tov3.MapException(ex);
219       } catch (SOAPFaultException ex) {
220          throw MapUDDIv2Tov3.MapException(ex);
221       }
222 
223    }
224 
225    @Override
226    public void setPublisherAssertions(String authInfo, Holder<List<PublisherAssertion>> publisherAssertion) throws DispositionReportFaultMessage, RemoteException {
227       try {
228          SetPublisherAssertions req = MapUDDIv3Tov2.MapSetPublisherAssertions(publisherAssertion.value);
229          req.setAuthInfo(authInfo);
230          PublisherAssertions setPublisherAssertions = publishService.setPublisherAssertions(req);
231          publisherAssertion.value = MapUDDIv2Tov3.MapListPublisherAssertion(setPublisherAssertions);
232 
233       } catch (DispositionReport ex) {
234          throw MapUDDIv2Tov3.MapException(ex);
235       } catch (SOAPFaultException ex) {
236          throw MapUDDIv2Tov3.MapException(ex);
237       }
238    }
239 
240    @Override
241    public Map<String, Object> getRequestContext() {
242       return ((BindingProvider) publishService).getRequestContext();
243    }
244 
245    @Override
246    public Map<String, Object> getResponseContext() {
247       return ((BindingProvider) publishService).getResponseContext();
248    }
249 
250    @Override
251    public Binding getBinding() {
252       return ((BindingProvider) publishService).getBinding();
253    }
254 
255    @Override
256    public EndpointReference getEndpointReference() {
257       return ((BindingProvider) publishService).getEndpointReference();
258    }
259 
260    @Override
261    public <T extends EndpointReference> T getEndpointReference(Class<T> clazz) {
262       return ((BindingProvider) publishService).getEndpointReference(clazz);
263    }
264 
265 }