if (root != null) {
NodeList photoList = root.getElementsByTagName("entry");
if (photoList != null && photoList.getLength() > 0) {
LOG.info("Found photos : " + photoList.getLength());
for (int i = 0; i < photoList.getLength(); i++) {
Photo photo = new Photo();
Element pl = (Element) photoList.item(i);
NodeList pid = pl.getElementsByTagNameNS(ALBUM_NAMESPACE,
"id");
String photoId = XMLParseUtil.getElementData(pid.item(0));
photo.setId(photoId);
photo.setTitle(XMLParseUtil.getElementData(pl, "title"));
NodeList mediaGroup = pl.getElementsByTagNameNS(
MEDIA_NAMESPACE, "group");
String urlLarge = null;
String urlMedium = null;
String urlSmall = null;
String urlThumb = null;
int width = 0;
if (mediaGroup != null && mediaGroup.getLength() > 0) {
Element el = (Element) mediaGroup.item(0);
if (el != null) {
NodeList content = el.getElementsByTagNameNS(
MEDIA_NAMESPACE, "content");
if (content != null) {
Element cl = (Element) content.item(0);
if (cl != null) {
urlLarge = cl.getAttribute("url");
}
}
NodeList thumbnail = el.getElementsByTagNameNS(
MEDIA_NAMESPACE, "thumbnail");
if (thumbnail != null && thumbnail.getLength() > 0) {
for (int k = 0; k < thumbnail.getLength(); k++) {
Element thumb = (Element) thumbnail.item(k);
if (thumb != null) {
width = Integer.parseInt(thumb
.getAttribute("width"));
if (width == 288) {
urlMedium = thumb
.getAttribute("url");
} else if (width == 144) {
urlSmall = thumb
.getAttribute("url");
} else if (width == 72) {
urlThumb = thumb
.getAttribute("url");
}
}
}
}
}
}
photo.setLargeImage(urlLarge);
photo.setMediumImage(urlMedium);
photo.setSmallImage(urlSmall);
photo.setThumbImage(urlThumb);
photos.add(photo);
}
} else {
LOG.info("No photos were obtained from : " + PHOTOS_URL);