return null;
}
@Override
protected void doService(ToolPageContext page) throws IOException, ServletException {
ToolUser user = page.getUser();
Collection<String> includeFields = Arrays.asList("returnToDashboardOnSave");
Object object = Query.from(Object.class).where("_id = ?", page.param(UUID.class, "id")).first();
State state = State.getInstance(object);
ContentLock contentLock = null;
if (object != null) {
contentLock = ContentLock.Static.lock(object, null, user);
}
if (page.isFormPost()) {
if (page.param(String.class, "action-edits") != null) {
if (state != null) {
Date newPublishDate = page.param(Date.class, "publishDate");
if (newPublishDate != null) {
Content.ObjectModification contentData = state.as(Content.ObjectModification.class);
DateTimeZone timeZone = page.getUserDateTimeZone();
newPublishDate = new Date(DateTimeFormat.
forPattern("yyyy-MM-dd HH:mm:ss").
withZone(timeZone).
parseMillis(new DateTime(newPublishDate).toString("yyyy-MM-dd HH:mm:ss")));
contentData.setPublishUser(page.getUser());
contentData.setPublishDate(newPublishDate);
state.save();
}
}
} else if (page.param(String.class, "action-unlock") != null) {
contentLock.delete();
page.writeStart("script", "type", "text/javascript");
page.writeRaw("window.location.reload();");
page.writeEnd();
} else if (page.param(String.class, "action-settings") != null) {
try {
page.include("/WEB-INF/objectPost.jsp", "object", user, "includeFields", includeFields);
user.save();
} catch (Exception error) {
page.getErrors().add(error);
}
}
}
String returnUrl = page.param(String.class, "returnUrl");
page.writeHeader();
page.writeStart("style", "type", "text/css");
page.writeCss(".cms-contentTools th",
"width", "25%;");
page.writeEnd();
page.writeStart("div", "class", "widget cms-contentTools");
page.writeStart("h1", "class", "icon icon-wrench");
page.writeHtml("Tools");
page.writeEnd();
page.writeStart("div", "class", "tabbed");
page.writeStart("div",
"class", "fixedScrollable",
"data-tab", "For Editors");
if (object != null) {
Content.ObjectModification contentData = state.as(Content.ObjectModification.class);
Date publishDate = contentData.getPublishDate();
ToolUser publishUser = contentData.getPublishUser();
Date updateDate = contentData.getUpdateDate();
ToolUser updateUser = contentData.getUpdateUser();
page.writeStart("table", "class", "table-striped");
page.writeStart("tbody");
if (publishDate != null || publishUser != null) {
page.writeStart("tr");