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 Specification, 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, context);
if (resolved != null && !resolved.isUnresolved()) {
imp.setDefinition(resolved.getDefinition());
if (!model.getImportedDefinitions().contains(resolved)) {
model.getImportedDefinitions().add(resolved);
}
}
} else {
String location = imp.getLocationURI();
if (location.indexOf(' ') != -1) {
location = location.replace(" ", "%20");
}
URI uri = URI.create(location);
if (uri.isAbsolute()) {
WSDLDefinition resolved;
try {
resolved = read(null, uri, uri.toURL(), context);
imp.setDefinition(resolved.getDefinition());
if (!model.getImportedDefinitions().contains(resolved)) {
model.getImportedDefinitions().add(resolved);
}
} catch (Exception e) {
ContributionResolveException ce = new ContributionResolveException(e);
error(monitor, "ContributionResolveException", resolver, ce);
//throw ce;
}
} 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(), context);
imp.setDefinition(resolved.getDefinition());
if (!model.getImportedDefinitions().contains(resolved)) {
model.getImportedDefinitions().add(resolved);
}
} catch (Exception e) {
ContributionResolveException ce = new ContributionResolveException(e);