Model exporter xml - how customize response content-type
Hi community,
i developed a custom XML exporter:
"
/**
* XML export used to generate XML render on servlets.
*/
@Component(service = ModelExporter.class)
public class CustomXmlExporter implements ModelExporter {
private static final Logger LOG = LoggerFactory.getLogger(CustomXmlExporter.class);
@Override
public boolean isSupported(Class<?> aClass) {
return true;
}
@Override
public <T> T export(Object model, Class<T> aClass, Map<String, String> options) throws ExportException {
StringWriter stringWriter = new StringWriter();
try {
JAXBContext jaxbContext = JAXBContext.newInstance(model.getClass());
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(model, stringWriter);
} catch (JAXBException e) {
LOG.error("\n Marshell Error : {} ",e);
}
return (T) stringWriter.toString();
}
@Override
public String getName() {
return "custom-exporter";
}
}
"
and it work fine!
now, during the integration test, i catched the necessary to customize the response content-type from:application/xml;charset=iso-8859-1 to:application/xml; charset=utf-8.
How can i reach the goal? i don't understand where set the content-type override.
Here my model:
@Exporters({
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, selector = "list", extensions = ExporterConstants.SLING_MODEL_EXTENSION, options = {
@ExporterOption(name = "MapperFeature.SORT_PROPERTIES_ALPHABETICALLY", value = "true"),
@ExporterOption(name = "SerializationFeature.WRITE_DATES_AS_TIMESTAMPS", value = "false")
}),
@Exporter(name = "custom-exporter", extensions = "xml", selector = "list")
})


