This project has retired. For details please refer to its Attic page.
ValidateUDDIv2Inquiry xref
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.validation;
17  
18  import org.apache.juddi.api.impl.UDDIv2InquiryImpl;
19  import org.apache.juddi.v3.client.mapping.MapUDDIv3Tov2;
20  import org.apache.juddi.v3.error.ErrorMessage;
21  import org.apache.juddi.v3.error.UnsupportedException;
22  import org.uddi.api_v2.FindBinding;
23  import org.uddi.api_v2.FindBusiness;
24  import org.uddi.api_v2.FindRelatedBusinesses;
25  import org.uddi.api_v2.FindService;
26  import org.uddi.api_v2.FindTModel;
27  import org.uddi.api_v2.GetBindingDetail;
28  import org.uddi.api_v2.GetBusinessDetail;
29  import org.uddi.api_v2.GetBusinessDetailExt;
30  import org.uddi.api_v2.GetServiceDetail;
31  import org.uddi.api_v2.GetTModelDetail;
32  import org.uddi.v2_service.DispositionReport;
33  
34  /**
35   *
36   * @author Alex O'Ree
37   */
38  public class ValidateUDDIv2Inquiry {
39  
40          public static final String VER = "2.0";
41  
42          public static void validateFindBinding(FindBinding body) throws DispositionReport {
43                  validateVersion(body.getGeneric());
44  
45          }
46  
47          public static void validateFindBusiness(FindBusiness body) throws DispositionReport {
48                  validateVersion(body.getGeneric());
49          }
50  
51          public static void validateFindRelatedBusinesses(FindRelatedBusinesses body) throws DispositionReport {
52                  validateVersion(body.getGeneric());
53          }
54  
55          public static void validateFindService(FindService body) throws DispositionReport {
56                  validateVersion(body.getGeneric());
57          }
58  
59          public static void validateFindTModel(FindTModel body) throws DispositionReport {
60                  validateVersion(body.getGeneric());
61          }
62  
63          public static void validateGetBindingDetail(GetBindingDetail body) throws DispositionReport {
64                  validateVersion(body.getGeneric());
65          }
66  
67          public static void validateGetBusinessDetail(GetBusinessDetail body) throws DispositionReport {
68                  validateVersion(body.getGeneric());
69          }
70  
71          public static void validateBusinessDetailExt(GetBusinessDetailExt body) throws DispositionReport {
72                  validateVersion(body.getGeneric());
73          }
74  
75          public static void validateGetServiceDetail(GetServiceDetail body) throws DispositionReport {
76                  validateVersion(body.getGeneric());
77          }
78  
79          public static void validateGetTModelDetail(GetTModelDetail body) throws DispositionReport {
80                  validateVersion(body.getGeneric());
81          }
82  
83          private static void validateVersion(String generic) throws DispositionReport {
84                  if (!VER.equalsIgnoreCase(generic)) {
85                          throw MapUDDIv3Tov2.MapException(new UnsupportedException(new ErrorMessage("E_unrecognizedVersion", generic)), UDDIv2InquiryImpl.getNodeID());
86                  }
87          }
88  
89  }