use of com.aliyun.oss.common.parser.ResponseParseException in project aliyun-oss-java-sdk by aliyun.
the class ResponseParsers method parseListLiveChannels.
/**
* Unmarshall list live channels response body to live channel listing.
*/
@SuppressWarnings("unchecked")
public static LiveChannelListing parseListLiveChannels(InputStream responseBody) throws ResponseParseException {
try {
Element root = getXmlRootElement(responseBody);
LiveChannelListing liveChannelListing = new LiveChannelListing();
liveChannelListing.setTruncated(Boolean.valueOf(root.getChildText("IsTruncated")));
if (root.getChild("Prefix") != null) {
String prefix = root.getChildText("Prefix");
liveChannelListing.setPrefix(isNullOrEmpty(prefix) ? null : prefix);
}
if (root.getChild("Marker") != null) {
String marker = root.getChildText("Marker");
liveChannelListing.setMarker(isNullOrEmpty(marker) ? null : marker);
}
if (root.getChild("MaxKeys") != null) {
String maxKeys = root.getChildText("MaxKeys");
liveChannelListing.setMaxKeys(Integer.valueOf(maxKeys));
}
if (root.getChild("NextMarker") != null) {
String nextMarker = root.getChildText("NextMarker");
liveChannelListing.setNextMarker(isNullOrEmpty(nextMarker) ? null : nextMarker);
}
List<Element> liveChannelElems = root.getChildren("LiveChannel");
for (Element elem : liveChannelElems) {
LiveChannel liveChannel = new LiveChannel();
liveChannel.setName(elem.getChildText("Name"));
liveChannel.setDescription(elem.getChildText("Description"));
liveChannel.setStatus(LiveChannelStatus.parse(elem.getChildText("Status")));
liveChannel.setLastModified(DateUtil.parseIso8601Date(elem.getChildText("LastModified")));
List<String> publishUrls = new ArrayList<String>();
List<Element> publishElems = elem.getChild("PublishUrls").getChildren("Url");
for (Element urlElem : publishElems) {
publishUrls.add(urlElem.getText());
}
liveChannel.setPublishUrls(publishUrls);
List<String> playUrls = new ArrayList<String>();
List<Element> playElems = elem.getChild("PlayUrls").getChildren("Url");
for (Element urlElem : playElems) {
playUrls.add(urlElem.getText());
}
liveChannel.setPlayUrls(playUrls);
liveChannelListing.addLiveChannel(liveChannel);
}
return liveChannelListing;
} catch (JDOMParseException e) {
throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
} catch (Exception e) {
throw new ResponseParseException(e.getMessage(), e);
}
}
Aggregations