@Override
public Post saveNewThread(final String topic, final String rawBody,
final Map<String, byte[]> attachments, final Long categoryId)
throws DataSourceException {
try {
final DiscussionThread thread = new DiscussionThread(topic);
if (categoryId != null) {
thread.setCategory(getCategory(categoryId));
}
mbMessageServiceContext.setAddCommunityPermissions(true);
mbMessageServiceContext.setAddGuestPermissions(true);
final MBMessage savedRootMessage = internalSaveAsCurrentUser(
rawBody, attachments, thread,
MBMessageConstants.DEFAULT_PARENT_MESSAGE_ID);
if (savedRootMessage != null) {
return getPost(savedRootMessage.getMessageId());
}
} catch (final NestableException e) {
LOG.error("Couldn't save new thread.", e);
if ("FileNameException".equals(e.getClass().getSimpleName())) {
throw new org.vaadin.tori.exception.FileNameException(e);
} else {
throw new DataSourceException(e);
}
}
throw new DataSourceException();
}