Definition definition = model.getDefinition();
if (definition != null) {
for (Object imports : definition.getImports().values()) {
List importList = (List)imports;
for (Object i : importList) {
Import imp = (Import)i;
if (imp.getDefinition() != null) {
continue;
}
if (imp.getLocationURI() == null) {
// FIXME: [rfeng] By the WSDL 1.1 spec, the location attribute is required
// We need to resolve it by QName
WSDLDefinition proxy = factory.createWSDLDefinition();
proxy.setUnresolved(true);
proxy.setNamespace(imp.getNamespaceURI());
WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, proxy);
if (resolved != null && !resolved.isUnresolved()) {
imp.setDefinition(resolved.getDefinition());
}
} else {
String location = imp.getLocationURI();
URI uri = URI.create(location);
if (uri.isAbsolute()) {
WSDLDefinition resolved;
try {
resolved = read(null, uri, uri.toURL());
imp.setDefinition(resolved.getDefinition());
} catch (Exception e) {
throw new ContributionResolveException(e);
}
} else {
if (location.startsWith("/")) {
// This is a relative URI against a contribution
location = location.substring(1);
// TODO: Need to resolve it against the contribution
} else {
// This is a relative URI against the WSDL document
URI baseURI = URI.create(model.getDefinition().getDocumentBaseURI());
URI locationURI = baseURI.resolve(location);
WSDLDefinition resolved;
try {
resolved = read(null, locationURI, locationURI.toURL());
imp.setDefinition(resolved.getDefinition());
} catch (Exception e) {
throw new ContributionResolveException(e);
}
}
}