- deserialize metadata.xml

This commit is contained in:
Richard Alam 2017-03-11 09:35:06 -08:00
parent f45acfaf53
commit 73b16db384
14 changed files with 324 additions and 20 deletions

View File

@ -34,6 +34,8 @@ libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaV
libraryDependencies += "commons-lang" % "commons-lang" % "2.5"
libraryDependencies += "org.freemarker" % "freemarker" % "2.3.23"
libraryDependencies += "com.fasterxml.jackson.dataformat" % "jackson-dataformat-xml" % "2.6.3"
// https://mvnrepository.com/artifact/org.codehaus.woodstox/woodstox-core-asl
libraryDependencies += "org.codehaus.woodstox" % "woodstox-core-asl" % "4.4.1"
libraryDependencies += "org.pegdown" % "pegdown" % "1.4.0" % "test"
libraryDependencies += "junit" % "junit" % "4.12" % "test"

View File

@ -0,0 +1,21 @@
package org.bigbluebutton.api.domain;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
public class Breakout {
/**
* <breakout parentMeetingId="f3ffe06acedf425565cc024c8ebe89a6552e8782-1489172964374" sequence="2" meetingId="f2041d123b6a4b994e7ad87ee9d348496a73472c-1489173065780"/>
*/
@JacksonXmlProperty(isAttribute = true)
private String parentMeetingId;
@JacksonXmlProperty(isAttribute = true)
private int sequence;
@JacksonXmlProperty(isAttribute = true)
private String meetingId;
}

View File

@ -0,0 +1,18 @@
package org.bigbluebutton.api.domain;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
public class BreakoutRoom {
@JacksonXmlText
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,21 @@
package org.bigbluebutton.api.domain;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
/**
* Created by ritz on 2017-03-11.
*/
public class Extensions {
@JacksonXmlProperty(localName = "preview")
@JacksonXmlElementWrapper(useWrapping = false)
private Preview preview;
public void setPreview(Preview preview) {
this.preview = preview;
}
public Preview getPreview() {
return preview;
}
}

View File

@ -0,0 +1,59 @@
package org.bigbluebutton.api.domain;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
public class Image {
/**
* <image width="176" height="136" alt="Welcome to">
* http://192.168.23.22/presentation/32ee8bcccfad34f85c58a12f87fc4268130a4fd3-1489173065780/presentation/743dd59a958334b4cdcdaa302846d0c0eadcf9ff-1489173070800/thumbnails/thumb-1.png
* </image>
*/
@JacksonXmlProperty(isAttribute = true)
private String width;
@JacksonXmlProperty(isAttribute = true)
private String height;
@JacksonXmlProperty(isAttribute = true)
private String alt;
@JacksonXmlText
private String value;
public void setWidth(String width) {
this.width = width;
}
public String getWidth() {
return width;
}
public void setHeight(String height) {
this.height = height;
}
public String getHeight() {
return height;
}
public void setAlt(String alt) {
this.alt = alt;
}
public String getAlt() {
return alt;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,23 @@
package org.bigbluebutton.api.domain;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import java.util.Map;
import java.util.TreeMap;
@JacksonXmlRootElement(localName = "meta")
public class Metadata {
private Map<String,String> map = new TreeMap<String,String>();
@JsonAnyGetter
public Map<String, String> get() {
return map;
}
@JsonAnySetter
public void set(String name, String value) {
map.put(name, value);
}
}

View File

@ -0,0 +1,18 @@
package org.bigbluebutton.api.domain;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
public class Preview {
@JacksonXmlElementWrapper(localName = "images")
@JacksonXmlProperty(localName = "image")
private Image[] images;
// public void setImages(Image[] images) {
// this.images = images;
// }
// public Image[] getImages() {
// return images;
// }
}

View File

@ -1,7 +1,120 @@
package org.bigbluebutton.api.domain;
/**
* Created by ralam on 3/10/2017.
*/
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import java.util.Map;
import java.util.TreeMap;
@JacksonXmlRootElement(localName = "recording")
public class RecordingMetadata {
/**
* <recording>
<id>32ee8bcccfad34f85c58a12f87fc4268130a4fd3-1489173065780</id>
<state>published</state>
<published>true</published>
<start_time>1489173065780</start_time>
<end_time>1489173199386</end_time>
<breakout parentMeetingId="f3ffe06acedf425565cc024c8ebe89a6552e8782-1489172964374" sequence="2" meetingId="f2041d123b6a4b994e7ad87ee9d348496a73472c-1489173065780"/>
<meta>
<meetingId>f2041d123b6a4b994e7ad87ee9d348496a73472c-1489173065780</meetingId>
<meetingName>random-2810069 (Room - 2)</meetingName>
<isBreakout>true</isBreakout>
</meta>
<playback>
<format>presentation</format>
<link>http://192.168.23.22/playback/presentation/0.9.0/playback.html?meetingId=32ee8bcccfad34f85c58a12f87fc4268130a4fd3-1489173065780</link>
<processing_time>9841</processing_time>
<duration>126376</duration>
<extensions>
<preview>
<images>
<image width="176" height="136" alt="Welcome to">http://192.168.23.22/presentation/32ee8bcccfad34f85c58a12f87fc4268130a4fd3-1489173065780/presentation/743dd59a958334b4cdcdaa302846d0c0eadcf9ff-1489173070800/thumbnails/thumb-1.png</image>
</images>
</preview>
</extensions>
</playback>
</recording>
*/
private String id;
private String state;
private boolean published;
@JacksonXmlProperty(localName = "start_time")
private String startTime;
@JacksonXmlProperty(localName = "end_time")
private String endTime;
private Breakout breakout;
@JacksonXmlElementWrapper(localName = "breakoutRooms")
@JacksonXmlProperty(localName = "breakoutRoom")
private BreakoutRoom[] breakoutRooms;
private Metadata meta;
private RecordingMetadataPlayback playback;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public void setState(String state) {
this.state = state;
}
public String getState() {
return state;
}
public void setPublished(boolean published) {
this.published = published;
}
public boolean getPublished() {
return published;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getStartTime() {
return startTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getEndTime() {
return endTime;
}
public void setBreakout(Breakout breakout) {
this.breakout = breakout;
}
public Breakout getBreakout() {
return breakout;
}
public void setMeta(Metadata meta) {
this.meta = meta;
}
public Metadata getMeta() {
return meta;
}
public RecordingMetadataPlayback getPlayback() {
return playback;
}
}

View File

@ -1,8 +0,0 @@
package org.bigbluebutton.api.domain
/**
* Created by ralam on 3/10/2017.
*/
class RecordingMetadataMeetingMeta {
}

View File

@ -13,6 +13,8 @@ public class RecordingMetadataPlayback {
private Long duration;
private Extensions extensions;
public void setFormat(String format) {
this.format = format;
}
@ -44,4 +46,12 @@ public class RecordingMetadataPlayback {
public Long getDuration() {
return duration;
}
public void setExtensions(Extensions extensions) {
this.extensions = extensions;
}
public Extensions getExtensions() {
return extensions;
}
}

View File

@ -5,6 +5,10 @@
<start_time>1489173065780</start_time>
<end_time>1489173199386</end_time>
<breakout parentMeetingId="f3ffe06acedf425565cc024c8ebe89a6552e8782-1489172964374" sequence="2" meetingId="f2041d123b6a4b994e7ad87ee9d348496a73472c-1489173065780"/>
<breakoutRooms>
<breakoutRoom>32ee8bcccfad34f85c58a12f87fc4268130a4fd3-1489173065780</breakoutRoom>
<breakoutRoom>721d83a3907548734d4a505992ebb94ec1454a91-1489173065780</breakoutRoom>
</breakoutRooms>
<meta>
<meetingId>f2041d123b6a4b994e7ad87ee9d348496a73472c-1489173065780</meetingId>
<meetingName>random-2810069 (Room - 2)</meetingName>

View File

@ -3,4 +3,5 @@
<link>http://192.168.23.22/playback/presentation/0.9.0/playback.html?meetingId=f3ffe06acedf425565cc024c8ebe89a6552e8782-1489095153417</link>
<processing_time>191283</processing_time>
<duration>545949</duration>
</playback>

View File

@ -4,17 +4,17 @@ import java.io.{File, FileInputStream}
import javax.xml.stream.{XMLInputFactory, XMLStreamReader}
import com.fasterxml.jackson.dataformat.xml.{JacksonXmlModule, XmlMapper}
import org.bigbluebutton.api.domain.RecordingMetadataPlayback
import org.bigbluebutton.api.domain.{RecordingMetadata, RecordingMetadataPlayback}
/**
* Created by ralam on 3/10/2017.
*/
class RecordingMetadataReaderHelperTest extends UnitSpec {
it should "find template" in {
it should "deserialize playback part of metadata.xml" in {
val factory: XMLInputFactory = XMLInputFactory.newInstance();
val templateLoc = new File("src/test/resources/playback-metadata.xml")
val xml = new File("src/test/resources/playback-metadata.xml")
val module: JacksonXmlModule = new JacksonXmlModule();
// and then configure, for example:
module.setDefaultUseWrapper(false);
@ -22,13 +22,35 @@ class RecordingMetadataReaderHelperTest extends UnitSpec {
val mapper: XmlMapper = new XmlMapper(module)
//Reading from xml file and creating XMLStreamReader
val reader: XMLStreamReader = factory.createXMLStreamReader(new FileInputStream(templateLoc))
val reader: XMLStreamReader = factory.createXMLStreamReader(new FileInputStream(xml))
val openCredentials: RecordingMetadataPlayback = mapper.readValue(reader, classOf[RecordingMetadataPlayback])
val playback: RecordingMetadataPlayback = mapper.readValue(reader, classOf[RecordingMetadataPlayback])
println(openCredentials)
println("***** FOOO =" + mapper.writeValueAsString(playback))
assert(playback.getDuration == 545949)
}
it should "deserialize metadata.xml" in {
val factory: XMLInputFactory = XMLInputFactory.newInstance();
val xml = new File("src/test/resources/breakout-room-metadata.xml")
val module: JacksonXmlModule = new JacksonXmlModule();
// and then configure, for example:
module.setDefaultUseWrapper(false);
val mapper: XmlMapper = new XmlMapper(module)
//Reading from xml file and creating XMLStreamReader
val reader: XMLStreamReader = factory.createXMLStreamReader(new FileInputStream(xml))
val recMeta: RecordingMetadata = mapper.readValue(reader, classOf[RecordingMetadata])
println("***** FOOO =" + mapper.writeValueAsString(recMeta))
assert(recMeta.getPlayback.getDuration == 126376)
assert(openCredentials.getDuration == 545949)
}
}

View File

@ -53,7 +53,7 @@ class ResponseBuilderTest extends UnitSpec {
val templateLoc = new File("src/test/resources")
val builder = new ResponseBuilder(templateLoc)
def response = builder.buildGetMeetingInfoResponse(meeting, "success")
println(response)
// println(response)
assert(templateLoc.exists())
}
@ -178,7 +178,7 @@ class ResponseBuilderTest extends UnitSpec {
val templateLoc = new File("src/test/resources")
val builder = new ResponseBuilder(templateLoc)
def response = builder.buildGetMeetingsResponse(meetings, "success")
println(response)
// println(response)
assert(templateLoc.exists())
}