boolean idDone = false;
boolean createdDone = false;
boolean modifiedDone = false;
boolean editedDone = false;
List<Child> toRemove = new ArrayList<Child>();
Element linkEdit = null;
Element linkEditMedia = null;
Element content = null;
Element author = null;
for (Child c : entry) {
if (c instanceof Element) {
Element e = (Element)c;
if (e.getName().equals(ID_NAME)) {
idDone = true;
e.clear();
e.addCharacters("urn:uuid:"+id.toString());
} else if (e.getName().equals(PUBLISHED_NAME) && created!=null) {
createdDone = true;
/*
e.clear();
e.addCharacters(toXSDDate(created));
*/
} else if (e.getName().equals(UPDATED_NAME)) {
modifiedDone = true;
} else if (e.getName().equals(EDITED_NAME)) {
editedDone = true;
e.clear();
e.setPrefix("app");
e.addCharacters(toXSDDate(modified));
} else if (e.getName().equals(AUTHOR_NAME)) {
author = e;
} else if (e.getName().equals(LINK_NAME)) {
String rel = e.getAttributeValue("rel");
if ("edit".equals(rel)) {
linkEdit = e;
} else if ("self".equals(rel)) {
toRemove.add(e);
} else if ("edit-media".equals(rel)) {
if (media!=null) {
linkEditMedia = e;
} else {
toRemove.add(e);
}
}
} else if (e.getName().equals(CONTENT_NAME)) {
content = e;
}
}
}
if (!modifiedDone) {
entry.addElement(0,UPDATED_NAME).addCharacters(toXSDDate(modified));
}
if (!editedDone) {
Element e = entry.addElement(0,EDITED_NAME);
e.addCharacters(toXSDDate(modified));
e.setPrefix("app");
}
if (!createdDone && created!=null) {
entry.addElement(0,PUBLISHED_NAME).addCharacters(toXSDDate(created));
}
if (!idDone) {