use of org.geotoolkit.feature.xml.jaxb.JAXBFeatureTypeReader in project geotoolkit by Geomatys.
the class ReferenceToFeatureTypeConverter method convert.
/**
* {@inheritDoc}
* @return FeatureType.
*/
@Override
public FeatureType convert(final Reference source, final Map<String, Object> params) throws UnconvertibleObjectException {
final String mime = source.getMimeType() != null ? source.getMimeType() : WPSMimeType.TEXT_XML.val();
final InputStream stream = getInputStreamFromReference(source);
// XML
if (mime.equalsIgnoreCase(WPSMimeType.TEXT_XML.val()) || mime.equalsIgnoreCase(WPSMimeType.APP_GML.val()) || mime.equalsIgnoreCase(WPSMimeType.TEXT_GML.val())) {
try {
final JAXBFeatureTypeReader xsdReader = new JAXBFeatureTypeReader();
final GenericNameIndex<FeatureType> ft = xsdReader.read(stream);
if (ft.getNames().size() != 1) {
throw new UnconvertibleObjectException("Invalid reference input : More than one FeatureType in schema.");
}
return ft.getValues().iterator().next();
} catch (JAXBException ex) {
throw new UnconvertibleObjectException("Invalid reference input : can't read reference schema.", ex);
}
} else {
throw new UnconvertibleObjectException("ReferenceType data mime is not supported");
}
}
Aggregations