+ "'. Building the schema manually instead.");
}
// user didn't define schema location
// import gml schema
XSDImport imprt = factory.createXSDImport();
imprt.setNamespace(gmlNamespace);
imprt.setSchemaLocation(ResponseUtils.buildSchemaURL(baseUrl, gmlSchemaLocation));
XSDSchema gmlSchema = gmlSchema();
imprt.setResolvedSchema(gmlSchema);
schema.getContents().add(imprt);
schema.getQNamePrefixToNamespaceMap().put(gmlPrefix, gmlNamespace);
schema.getQNamePrefixToNamespaceMap().put("gml", "http://www.opengis.net/gml");
// then manually build schema
for (int i = 0; i < featureTypeInfos.length; i++) {
try {
buildSchemaContent(featureTypeInfos[i], schema, factory, baseUrl);
} catch (Exception e) {
logger.log(Level.WARNING, "Could not build xml schema for type: "
+ featureTypeInfos[i].getName(), e);
}
}
} else {
//different namespaces, write out import statements
ArrayList<String> importedNamespaces = new ArrayList<String>(
ns2featureTypeInfos.size() + 1);
for (Iterator i = ns2featureTypeInfos.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
String prefix = (String) entry.getKey();
List types = (List) entry.getValue();
StringBuffer typeNames = new StringBuffer();
String namespaceURI;
for (Iterator t = types.iterator(); t.hasNext();) {
FeatureTypeInfo info = (FeatureTypeInfo) t.next();
FeatureType featureType = info.getFeatureType();
Object schemaUri = featureType.getUserData().get("schemaURI");
if (schemaUri != null) {
// should always be a string.. set in AppSchemaDataAccessConfigurator
assert schemaUri instanceof String;
// schema is supplied by the user.. just import the top level schema instead of
// building
// the type
namespaceURI = featureType.getName().getNamespaceURI();
addImport(schema, factory, namespaceURI,
(String) schemaUri, importedNamespaces);
// ensure there's only 1 import per namespace
importedNamespaces.add(namespaceURI);
} else {
typeNames.append(info.getPrefixedName()).append(",");
}
}
if (typeNames.length() > 0) {
typeNames.setLength(typeNames.length()-1);
// schema not found, encode describe feature type URL
Map<String, String> params = new LinkedHashMap<String, String>(describeFeatureTypeParams);
params.put("typeName", typeNames.toString().trim());
String schemaLocation = buildURL(baseUrl, "wfs", params, URLType.RESOURCE);
String namespace = catalog.getNamespaceByPrefix(prefix).getURI();
XSDImport imprt = factory.createXSDImport();
imprt.setNamespace(namespace);
imprt.setSchemaLocation(schemaLocation);
schema.getContents().add(imprt);
}
}
}