use of com.fasterxml.jackson.dataformat.xml.JacksonXmlModule in project bigbluebutton by bigbluebutton.
the class RecordingMetadataReaderHelper method saveRecordingMetadata.
public static void saveRecordingMetadata(File metadataXml, RecordingMetadata recordingMetadata) {
//XMLOutputFactory factory = XMLOutputFactory.newInstance();
JacksonXmlModule module = new JacksonXmlModule();
module.setDefaultUseWrapper(false);
XmlMapper mapper = new XmlMapper(module);
//XMLStreamWriter writer = null;
try {
//writer = factory.createXMLStreamWriter(new FileOutputStream(metadataXml));
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.writeValue(metadataXml, recordingMetadata);
} catch (FileNotFoundException e) {
log.error("File not found: " + metadataXml.getAbsolutePath(), e);
} catch (IOException e) {
log.error("IOException on " + metadataXml.getAbsolutePath(), e);
}
}
use of com.fasterxml.jackson.dataformat.xml.JacksonXmlModule in project bigbluebutton by bigbluebutton.
the class RecordingMetadataReaderHelper method getRecordingMetadata.
public static RecordingMetadata getRecordingMetadata(File metadataXml) {
XMLInputFactory factory = XMLInputFactory.newInstance();
JacksonXmlModule module = new JacksonXmlModule();
// and then configure, for example:
module.setDefaultUseWrapper(false);
XmlMapper mapper = new XmlMapper(module);
//Reading from xml file and creating XMLStreamReader
XMLStreamReader reader = null;
RecordingMetadata recMeta = null;
try {
reader = factory.createXMLStreamReader(new FileInputStream(metadataXml));
recMeta = mapper.readValue(reader, RecordingMetadata.class);
} catch (XMLStreamException e) {
log.error("Failed to read metadata xml for recording: " + metadataXml.getAbsolutePath(), e);
} catch (FileNotFoundException e) {
log.error("File not found: " + metadataXml.getAbsolutePath(), e);
} catch (IOException e) {
log.error("IOException on " + metadataXml.getAbsolutePath(), e);
}
return recMeta;
}
use of com.fasterxml.jackson.dataformat.xml.JacksonXmlModule in project ninja by ninjaframework.
the class ApiControllerTest method testGetAndPostArticleViaXml.
@Test
public void testGetAndPostArticleViaXml() throws Exception {
// /////////////////////////////////////////////////////////////////////
// Test initial data:
// /////////////////////////////////////////////////////////////////////
String response = ninjaTestBrowser.makeXmlRequest(getServerAddress() + "api/bob@gmail.com/articles.xml");
System.out.println("response xml: " + response);
JacksonXmlModule module = new JacksonXmlModule();
// and then configure, for example:
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
ArticlesDto articlesDto = xmlMapper.readValue(response, ArticlesDto.class);
assertEquals(3, articlesDto.articles.size());
// /////////////////////////////////////////////////////////////////////
// Post new article:
// /////////////////////////////////////////////////////////////////////
ArticleDto articleDto = new ArticleDto();
articleDto.content = "contentcontent";
articleDto.title = "new title new title";
response = ninjaTestBrowser.postXml(getServerAddress() + "api/bob@gmail.com/article.xml", articleDto);
assertTrue(response.contains("Error. Forbidden."));
doLogin();
response = ninjaTestBrowser.postXml(getServerAddress() + "api/bob@gmail.com/article.xml", articleDto);
assertFalse(response.contains("Error. Forbidden."));
// /////////////////////////////////////////////////////////////////////
// Fetch articles again => assert we got a new one ...
// /////////////////////////////////////////////////////////////////////
response = ninjaTestBrowser.makeXmlRequest(getServerAddress() + "api/bob@gmail.com/articles.xml");
articlesDto = xmlMapper.readValue(response, ArticlesDto.class);
// one new result:
assertEquals(4, articlesDto.articles.size());
}
use of com.fasterxml.jackson.dataformat.xml.JacksonXmlModule in project ninja by ninjaframework.
the class XmlMapperProvider method get.
@Override
public XmlMapper get() {
JacksonXmlModule module = new JacksonXmlModule();
// Check out: https://github.com/FasterXML/jackson-dataformat-xml
// setDefaultUseWrapper produces more similar output to
// the Json output. You can change that with annotations in your
// models.
module.setDefaultUseWrapper(false);
XmlMapper xmlMapper = new XmlMapper(module);
xmlMapper.registerModule(new AfterburnerModule());
return xmlMapper;
}
Aggregations