<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ page import="org.crosswire.utils.HTTPUtils" %> <%@ page import="com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil" %> <%@ page import="com.liferay.portlet.messageboards.model.MBMessage" %> <%@ page import="com.liferay.portal.service.ServiceContext" %> <%@ page import="com.liferay.portal.kernel.util.ObjectValuePair" %> <%@ page import="java.util.List" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.io.InputStream" %> <%@ page import="org.crosswire.xml.XMLBlock" %> <%@ page import="org.crosswire.webtools.annotation.*" %> <%@ page import="org.crosswire.webtools.*" %> <%@ page import="javax.validation.constraints.NotNull" %> <%@ page import="org.crosswire.community.projects.ntmss.data.Transcription" %> <%! @Description(value = "Put a new message.", name = "forum/message/put") public static class MyParameters extends Parameters { @NotNull @Description(value = "forum group context", example = "12") public Integer groupID; @NotNull @Description(value = "category of messages to create", example = "120") public Integer categoryID; @NotNull @Description(value = "subject of message", example = "My Message Subject") public String subject; @NotNull @Description(value = "body of message", example = "This is my message body") public String body; @NotNull @Description(value = "whether or not to post. If false, only a draft will be made", defaultValue = "false", example = "true") public Boolean postImmediately = false; @Override protected void afterLoad() { subject = Transcription.assureUnicode(subject); body = Transcription.assureUnicode(body); } @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) { long userID = Long.parseLong(params.getUser().getInternalUserID()); params.getLogger().info("forum/message/put(userID:"+userID+", groupID:"+params.groupID+", categoryID:"+params.categoryID+", subject:"+params.subject+", body:"+params.body+", postImmediately:"+params.postImmediately+")"); ServiceContext sc = new ServiceContext(); sc.setScopeGroupId(params.groupID); sc.setUserId(userID); sc.setAddGroupPermissions(true); sc.setAddGuestPermissions(true); sc.setWorkflowAction(params.postImmediately ? 1 : 0); List>streams = new ArrayList>(); MBMessage msg = MBMessageLocalServiceUtil.addMessage(userID, params.getUser().getUserName(), params.groupID, params.categoryID, params.subject, params.body, "html", streams, false, 0.0, true, sc); Serializer.output(response, out, params, XMLBlock.createXMLBlock("")); params.getLogger().info("success. msgID:"+msg.getMessageId()); return; } else params.format = "html"; Serializer.reportErrors(request, response, out, params, true); %>