use of nl.nn.adapterframework.soap.SoapVersion in project iaf by ibissource.
the class SchemaLocation method getXsds.
@Override
public Set<XSD> getXsds() throws ConfigurationException {
Set<XSD> xsds = new HashSet<XSD>();
SoapVersion soapVersion = getSoapVersion();
if (soapVersion == null || soapVersion == SoapVersion.SOAP11 || soapVersion == SoapVersion.AUTO) {
XSD xsd = new XSD();
xsd.initNamespace(SoapVersion.SOAP11.namespace, this, SoapVersion.SOAP11.location);
xsds.add(xsd);
}
if (soapVersion == SoapVersion.SOAP12 || soapVersion == SoapVersion.AUTO) {
XSD xsd = new XSD();
xsd.initNamespace(SoapVersion.SOAP12.namespace, this, SoapVersion.SOAP12.location);
xsds.add(xsd);
}
if (StringUtils.isNotEmpty(getSchemaLocationToAdd())) {
StringTokenizer st = new StringTokenizer(getSchemaLocationToAdd(), ", \t\r\n\f");
while (st.hasMoreTokens()) {
XSD xsd = new XSD();
xsd.initNamespace(st.nextToken(), this, st.hasMoreTokens() ? st.nextToken() : null);
xsds.add(xsd);
}
}
List<Schema> schemas = new ArrayList<Schema>();
List<ExtensibilityElement> types = definition.getTypes().getExtensibilityElements();
for (Iterator<ExtensibilityElement> i = types.iterator(); i.hasNext(); ) {
ExtensibilityElement type = i.next();
QName qn = type.getElementType();
if (SchemaUtils.WSDL_SCHEMA.equals(qn)) {
final Schema schema = (Schema) type;
addNamespaces(schema, definition.getNamespaces());
schemas.add(schema);
}
}
List<Schema> filteredSchemas;
Map<Schema, String> filteredReferences = null;
Map<Schema, String> filteredNamespaces = null;
if (StringUtils.isEmpty(getSchemaLocation())) {
filteredSchemas = schemas;
} else {
filteredSchemas = new ArrayList<Schema>();
filteredReferences = new HashMap<Schema, String>();
filteredNamespaces = new HashMap<Schema, String>();
String[] split = getSchemaLocation().trim().split("\\s+");
if (split.length % 2 != 0)
throw new ConfigurationException("The schema must exist from an even number of strings, but it is [" + getSchemaLocation() + "]");
for (int i = 0; i < split.length; i += 2) {
if (!split[i + 1].startsWith(RESOURCE_INTERNAL_REFERENCE_PREFIX)) {
throw new ConfigurationException("Schema reference " + split[i + 1] + " should start with '" + RESOURCE_INTERNAL_REFERENCE_PREFIX + "'");
}
try {
int j = Integer.parseInt(split[i + 1].substring(RESOURCE_INTERNAL_REFERENCE_PREFIX.length())) - 1;
filteredSchemas.add(schemas.get(j));
filteredReferences.put(schemas.get(j), RESOURCE_INTERNAL_REFERENCE_PREFIX + (j + 1));
filteredNamespaces.put(schemas.get(j), split[i]);
} catch (Exception e) {
throw new ConfigurationException("Schema reference " + split[i + 1] + " not valid or not found");
}
}
}
for (Schema schema : filteredSchemas) {
XSD xsd = new XSD();
xsd.setWsdlSchema(definition, schema);
if (StringUtils.isNotEmpty(getSchemaLocation())) {
xsd.setResourceInternalReference(filteredReferences.get(schema));
// xsd.setNamespace(filteredNamespaces.get(schema));
} else {
xsd.setResourceInternalReference(RESOURCE_INTERNAL_REFERENCE_PREFIX + (filteredSchemas.indexOf(schema) + 1));
}
xsd.setAddNamespaceToSchema(isAddNamespaceToSchema());
xsd.setImportedSchemaLocationsToIgnore(getImportedSchemaLocationsToIgnore());
xsd.setUseBaseImportedSchemaLocationsToIgnore(isUseBaseImportedSchemaLocationsToIgnore());
xsd.setImportedNamespacesToIgnore(getImportedNamespacesToIgnore());
xsd.initNamespace(StringUtils.isNotEmpty(getSchemaLocation()) ? filteredNamespaces.get(schema) : null, this, getWsdl());
xsds.add(xsd);
}
return xsds;
}
Aggregations