if (!automaticallySavedDrafts.isEmpty()) {
boolean removed = false;
for (Iterator<Object> i = automaticallySavedDrafts.iterator(); i.hasNext();) {
State draft = State.getInstance(i.next());
if (!draft.as(Content.ObjectModification.class).isDraft()) {
removed = true;
automaticallySavedDraftIds.remove(draft.getId());
i.remove();
}
}
if (removed) {
user.save();
}
if (!automaticallySavedDrafts.isEmpty()) {
page.writeStart("h2").writeHtml("Automatically Saved Drafts").writeEnd();
page.writeStart("ul", "class", "links");
for (Object draft : automaticallySavedDrafts) {
page.writeStart("li");
page.writeStart("a",
"target", "_top",
"href", page.objectUrl("/content/edit.jsp", draft));
page.writeTypeObjectLabel(draft);
page.writeEnd();
page.writeEnd();
}
page.writeEnd();
}
}
page.writeStart("div", "style", page.cssString(
"-moz-box-sizing", "border-box",
"-webkit-box-sizing", "border-box",
"box-sizing", "border-box",
"float", "left",
"padding-right", "5px",
"width", "50%"));
page.writeStart("h2").writeHtml("Create New").writeEnd();
page.writeStart("ul", "class", "links pageThumbnails");
for (TypeTemplate typeTemplate : favorites) {
ObjectType type = typeTemplate.type;
Template template = typeTemplate.template;
State state = State.getInstance(Query.fromType(type).where("cms.template.default = ?", template).first());
String permalink = null;
if (state != null) {
permalink = state.as(Directory.ObjectModification.class).getPermalink();
}
page.writeStart("li", "data-preview-url", permalink);
page.writeStart("a",
"target", "_top",