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:
20: package org.apache.axis2.wsdl.codegen.extension;
21:
22: import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
23: import org.apache.axis2.wsdl.codegen.CodeGenerationException;
24: import org.apache.axis2.wsdl.i18n.CodegenMessages;
25: import org.apache.ws.commons.schema.XmlSchema;
26:
27: import java.util.List;
28:
29: public class WSDLValidatorExtension extends
30: AbstractCodeGenerationExtension {
31:
32: public void engage(CodeGenConfiguration configuration)
33: throws CodeGenerationException {
34: //WSDLDescription wom = this.configuration.getWom();
35: List schemaList = configuration.getSchemaListForAllServices();
36: if (schemaList == null || schemaList.isEmpty()) {
37: //there are no types to be considered
38: return;
39: }
40:
41: for (int i = 0; i < schemaList.size(); i++) {
42: XmlSchema s = (XmlSchema) schemaList.get(i);
43: if (s.getIncludes().getCount() != 0) {
44: //there are some included - now see whether there are any
45: //elements or types declared!
46: if (s.getElements().getCount() == 0
47: && s.getSchemaTypes().getCount() == 0
48: && s.getGroups().getCount() == 0
49: && s.getTargetNamespace() == null) {
50: // if there's no targetNamespace there's probably no name, but try it anyway
51: throw new CodeGenerationException(CodegenMessages
52: .getMessage("extension.invalidWSDL", s
53: .toString()));
54: }
55:
56: }
57: }
58:
59: }
60: }
|