%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>
<%@ page import="com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil" %>
<%@ page import="org.crosswire.xml.XMLBlock" %>
<%@ page import="org.crosswire.webtools.annotation.*" %>
<%@ page import="org.crosswire.webtools.*" %>
<%@ page import="javax.validation.constraints.NotNull" %>
<%!
@Description(value = "Delete a message.", name = "forum/message/delete")
public static class MyParameters extends Parameters {
@NotNull
@Description(value = "id of message to delete", example = "12")
public Integer messageID;
@Override
protected void customValidation() {
if (getUser() == null) {
addError(-5, "Must be logged in.");
return;
}
}
}
%>
<%
MyParameters params = new MyParameters().loadFromRequest(request, response, false);
if (params.getErrors().size() == 0) {
if (!params.getUser().hasRole("VMR Administrator")) {
params.addError(-6, "Must be a VMR Administrator to delete Forum Messages.");
}
else {
params.getLogger().info("forum/message/delete(messageID:"+params.messageID + "; userName: " + params.getUser().getUserName());
try {
MBMessageLocalServiceUtil.deleteMessage(params.messageID);
Serializer.output(response, out, params, XMLBlock.createXMLBlock(""));
return;
}
catch (Exception e) {
params.addError(-7, e.toString());
}
}
}
else params.format = "html";
Serializer.reportErrors(request, response, out, params, true);
%>