* directly. If the given content is a Trash-Object, the Trash-Object is
* deleted only when it is empty, otherwise the Trash will be emptied.
*/
public static void delete(Content content) {
if (content instanceof Trash) {
Trash trash = (Trash) content;
if (trash.isEmpty()) {
Nodes.delete(trash);
} else {
for (Content child : trash.getChildren(Content.class)) {
if (child.getParent() != null
&& Contents.isDeletable(child)) {
delete(child);
}
}
Nodes.save(trash);
}
} else {
Trash trash = content.getParent() != null ? ((Content) content
.getParent()).getGuard(Trash.class) : null;
if (trash == null || content.isDescendant(trash)) {
if (isDeletable(content)) {
deleteReferences(content);
Nodes.delete(content);
}
} else {
trash.appendChild(content);
Nodes.save(trash);
}
}
}