public ServiceContext getServiceContext() { ServiceContext serviceContext = new ServiceContext(); ThemeDisplay themeDisplay = getThemeDisplay(); serviceContext.setCompanyId(themeDisplay.getCompanyId()); serviceContext.setLanguageId(themeDisplay.getLanguageId()); serviceContext.setPathMain(PortalUtil.getPathMain()); serviceContext.setPlid(themeDisplay.getPlid()); serviceContext.setPortalURL(PortalUtil.getPortalURL(getPortletRequest())); serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId()); serviceContext.setUserId(themeDisplay.getUserId()); try { serviceContext.setLayoutFullURL(PortalUtil.getLayoutFullURL(themeDisplay)); serviceContext.setLayoutURL(PortalUtil.getLayoutURL(themeDisplay)); serviceContext.setUserDisplayURL(themeDisplay.getUser().getDisplayURL(themeDisplay)); } catch (Exception e) { logger.error(e.getMessage(), e); } return serviceContext; }
@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); } } }
private void addAutoComment(Idea idea, long classPK, String message) { try { String threadView = PropsKeys.DISCUSSION_THREAD_VIEW; MBMessageDisplay messageDisplay = mbMessageLocalService.getDiscussionMessageDisplay( idea.getUserId(), idea.getGroupId(), IdeaContent.class.getName(), classPK, WorkflowConstants.STATUS_ANY, threadView); MBThread thread = messageDisplay.getThread(); long threadId = thread.getThreadId(); long rootThreadId = thread.getRootMessageId(); ServiceContext serviceContext = new ServiceContext(); long userId = Long.valueOf(autoCommentDefaultUserId); mbMessageLocalService.addDiscussionMessage(userId, autoCommentDefaultUserId, idea.getGroupId(), IdeaContent.class.getName(), idea.getIdeaContentPrivate().getId(), threadId, rootThreadId, autoCommentDefaultSubject, message, serviceContext); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } }
user.getPortraitId(), imagePath, user.isFemale()); if (userAvatarUrl != null) { avatarUrl = mbMessageServiceContext.getPortalURL() + userAvatarUrl; LiferayDataSource.PREFS_EMAIL_HEADER_IMAGE_URL, null); String threadUrl = mbMessageServiceContext.getLayoutFullURL() + "#!/thread/" + mbMessage.getThreadId();
@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(); }
public ServiceContext getServiceContext() { ServiceContext serviceContext = new ServiceContext(); ThemeDisplay themeDisplay = getThemeDisplay(); serviceContext.setCompanyId(themeDisplay.getCompanyId()); serviceContext.setLanguageId(themeDisplay.getLanguageId()); serviceContext.setPathMain(PortalUtil.getPathMain()); serviceContext.setPlid(themeDisplay.getPlid()); serviceContext.setPortalURL(PortalUtil.getPortalURL(getPortletRequest())); serviceContext.setScopeGroupId(themeDisplay.getScopeGroupId()); serviceContext.setUserId(themeDisplay.getUserId()); try { serviceContext.setLayoutFullURL(PortalUtil.getLayoutFullURL(themeDisplay)); serviceContext.setLayoutURL(PortalUtil.getLayoutURL(themeDisplay)); serviceContext.setUserDisplayURL(themeDisplay.getUser().getDisplayURL(themeDisplay)); } catch (Exception e) { logger.error(e.getMessage(), e); } return serviceContext; }