/* * SoapUI, Copyright (C) 2004-2016 SmartBear Software * * Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent * versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * * http://ec.europa.eu/idabc/eupl * * Unless required by applicable law or agreed to in writing, software distributed under the Licence is * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the Licence for the specific language governing permissions and limitations * under the Licence. */ package com.eviware.soapui.impl.support.definition.support; import com.eviware.soapui.impl.support.AbstractInterface; import com.eviware.soapui.impl.support.definition.DefinitionLoader; import com.eviware.soapui.impl.wsdl.support.xsd.SchemaException; import com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.SchemaTypeSystem; import org.apache.xmlbeans.XmlBeans; import javax.xml.namespace.QName; import java.util.Collection; import java.util.HashSet; import java.util.Set; public abstract class XmlSchemaBasedInterfaceDefinition<T extends AbstractInterface<?>> extends AbstractInterfaceDefinition<T> { private SchemaTypeSystem schemaTypes; private SchemaTypeLoader schemaTypeLoader; public XmlSchemaBasedInterfaceDefinition(T iface) { super(iface); } public SchemaTypeLoader getSchemaTypeLoader() { return schemaTypeLoader; } public SchemaTypeSystem getSchemaTypeSystem() { return schemaTypes; } public boolean hasSchemaTypes() { return schemaTypes != null; } public Collection<String> getDefinedNamespaces() throws Exception { Set<String> namespaces = new HashSet<String>(); SchemaTypeSystem schemaTypes = getSchemaTypeSystem(); if (schemaTypes != null) { namespaces.addAll(SchemaUtils.extractNamespaces(getSchemaTypeSystem(), true)); } namespaces.add(getTargetNamespace()); return namespaces; } public SchemaType findType(QName typeName) { return getSchemaTypeLoader().findType(typeName); } public void loadSchemaTypes(DefinitionLoader loader) throws SchemaException { schemaTypes = SchemaUtils.loadSchemaTypes(loader.getBaseURI(), loader); schemaTypeLoader = XmlBeans.typeLoaderUnion(new SchemaTypeLoader[]{schemaTypes, XmlBeans.getBuiltinTypeSystem()}); } }