01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.description.validator;
20:
21: import java.util.Collection;
22:
23: import org.apache.axis2.jaxws.description.EndpointDescription;
24: import org.apache.axis2.jaxws.description.ServiceDescription;
25: import org.apache.axis2.jaxws.description.ServiceDescriptionJava;
26: import org.apache.axis2.jaxws.description.ServiceDescriptionWSDL;
27:
28: /**
29: *
30: */
31: public class ServiceDescriptionValidator extends Validator {
32:
33: private ServiceDescription serviceDesc;
34: private ServiceDescriptionJava serviceDescJava;
35: private ServiceDescriptionWSDL serviceDescWSDL;
36:
37: public ServiceDescriptionValidator(ServiceDescription toValidate) {
38: serviceDesc = toValidate;
39: serviceDescJava = (ServiceDescriptionJava) serviceDesc;
40: serviceDescWSDL = (ServiceDescriptionWSDL) serviceDesc;
41: }
42:
43: /**
44: * Validate the ServiceDescription as follows 1) Validate that annotations and whatever WSDL is
45: * specified is valid 2) Validate that Java implementations are correc a) Service
46: * Implementations match SEIs if specified b) Operations match SEI methods
47: *
48: * @return true if the ServiceDescription is valid
49: */
50: public boolean validate() {
51: if (getValidationLevel() == ValidationLevel.OFF) {
52: return VALID;
53: }
54:
55: if (!validateEndpointDescriptions()) {
56: return INVALID;
57: }
58:
59: return VALID;
60: }
61:
62: private boolean validateEndpointDescriptions() {
63: boolean areAllValid = true;
64: // Validate all the Endpoints that were created under this Service Description
65: Collection<EndpointDescription> endpointDescs = serviceDesc
66: .getEndpointDescriptions_AsCollection();
67: for (EndpointDescription endpointDesc : endpointDescs) {
68: EndpointDescriptionValidator endpointValidator = new EndpointDescriptionValidator(
69: endpointDesc);
70:
71: boolean isEndpointValid = endpointValidator.validate();
72: if (!isEndpointValid) {
73: addValidationFailure(endpointValidator,
74: "Endpoint failed validation");
75: areAllValid = false;
76: }
77: }
78: return areAllValid;
79: }
80:
81: }
|