@Override public void saveNewCategory(final Long parentCategoryId, final String name, final String description) throws DataSourceException { try { LOG.debug("Adding new category: " + name); final long parentId = normalizeCategoryId(parentCategoryId); final String displayStyle = "default"; mbCategoryServiceContext.setAddGroupPermissions(true); mbCategoryServiceContext.setAddGuestPermissions(true); MBCategoryServiceUtil.addCategory(parentId, name, description, displayStyle, null, null, null, 0, false, null, null, 0, null, false, null, 0, false, null, null, false, false, mbCategoryServiceContext); } catch (final NestableException e) { LOG.error("Cannot persist category", e); throw new DataSourceException(e); } }
@Override public Post saveReply(final String rawBody, final Map<String, byte[]> attachments, final long threadId) throws DataSourceException { try { mbMessageServiceContext.setAddCommunityPermissions(true); mbMessageServiceContext.setAddGuestPermissions(true); final MBMessage newPost = internalSaveAsCurrentUser(rawBody, attachments, getThread(threadId), getRootMessageId(threadId)); markThreadRead(threadId); return getPost(newPost.getMessageId()); } catch (final NestableException e) { LOG.error("Couldn't save post.", e); if ("FileNameException".equals(e.getClass().getSimpleName())) { throw new org.vaadin.tori.exception.FileNameException(e); } else { throw new DataSourceException(e); } } }
@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); } } // if we get this far, saving has failed -> throw exception throw new DataSourceException(); }