}
try {
Element ownerElement = (Element) photoElement.getElementsByTagName("owner").item(0);
if (ownerElement == null) {
User owner = new User();
owner.setId(getAttribute("owner", photoElement, defaultElement));
owner.setUsername(getAttribute("ownername", photoElement, defaultElement));
photo.setOwner(owner);
photo.setUrl("http://flickr.com/photos/" + owner.getId() + "/" + photo.getId());
} else {
User owner = new User();
owner.setId(ownerElement.getAttribute("nsid"));
String username = ownerElement.getAttribute("username");
String ownername = ownerElement.getAttribute("ownername");
// try to get the username either from the "username" attribute or
// from the "ownername" attribute
if (username != null && !"".equals(username)) {
owner.setUsername(username);
} else if (ownername != null && !"".equals(ownername)) {
owner.setUsername(ownername);
}
owner.setUsername(ownerElement.getAttribute("username"));
owner.setRealName(ownerElement.getAttribute("realname"));
owner.setLocation(ownerElement.getAttribute("location"));
photo.setOwner(owner);
photo.setUrl("http://flickr.com/photos/" + owner.getId() + "/" + photo.getId());
}
} catch (IndexOutOfBoundsException e) {
User owner = new User();
owner.setId(photoElement.getAttribute("owner"));
owner.setUsername(photoElement.getAttribute("ownername"));
photo.setOwner(owner);
photo.setUrl("http://flickr.com/photos/" + owner.getId() + "/" + photo.getId());
}
try {
photo.setTitle(XMLUtilities.getChildValue(photoElement, "title"));
if (photo.getTitle() == null) {