public void mergeEntry(final Txn transaction, final ElementImpl target,
Element source, final String updated) {
final List<Node> toRemove = new ArrayList<Node>();
DOM.forEachChild(target, new NodeHandler() {
@Override
public void process(Node parent, Node child) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
final String ns = child.getNamespaceURI();
if (ns != null && ns.equals(Atom.NAMESPACE_STRING)) {
final String lname = child.getLocalName();
if ("updated".equals(lname)) {
// Changed updated
DOMDB.replaceText(transaction, (ElementImpl) child,
updated);
} else if ("link".equals(lname)) {
final String rel = ((Element) child).getAttribute("rel");
if (!"edit".equals(rel)
&& !"edit-media".equals(rel)) {
// remove it
toRemove.add(child);
}
} else if (!"id".equals(lname)
&& !"published".equals(lname)) {
// remove it
toRemove.add(child);
}
} else {
// remove it
toRemove.add(child);
}
} else {
toRemove.add(child);
}
}
});
for (final Node child : toRemove) {
target.removeChild(transaction, child);
}
DOM.forEachChild(source, new NodeHandler() {
@Override
public void process(Node parent, Node child) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
final String ns = child.getNamespaceURI();
if (ns != null && ns.equals(Atom.NAMESPACE_STRING)) {