コード例 #1
0
  public static com.liferay.portlet.messageboards.model.MBMessageSoap updateMessage(
      long messageId,
      java.lang.String subject,
      java.lang.String body,
      java.util.List<
              com.liferay.portal.kernel.util.ObjectValuePair<java.lang.String, java.io.InputStream>>
          inputStreamOVPs,
      java.util.List<java.lang.String> existingFiles,
      double priority,
      boolean allowPingbacks,
      com.liferay.portal.service.ServiceContext serviceContext)
      throws RemoteException {
    try {
      com.liferay.portlet.messageboards.model.MBMessage returnValue =
          MBMessageServiceUtil.updateMessage(
              messageId,
              subject,
              body,
              inputStreamOVPs,
              existingFiles,
              priority,
              allowPingbacks,
              serviceContext);

      return com.liferay.portlet.messageboards.model.MBMessageSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #2
0
  @Override
  public boolean include(HttpServletRequest request, HttpServletResponse response, String template)
      throws Exception {

    MBMessageDisplay messageDisplay =
        MBMessageServiceUtil.getMessageDisplay(
            _rootMessage.getMessageId(),
            WorkflowConstants.STATUS_ANY,
            MBThreadConstants.THREAD_VIEW_TREE,
            false);

    request.setAttribute(WebKeys.MESSAGE_BOARDS_MESSAGE, messageDisplay);

    MBTreeWalker treeWalker = messageDisplay.getTreeWalker();

    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER, treeWalker);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_CATEGORY, messageDisplay.getCategory());
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_CUR_MESSAGE, treeWalker.getRoot());
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_DEPTH, Integer.valueOf(0));
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_LAST_NODE, Boolean.FALSE);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_SEL_MESSAGE, _rootMessage);
    request.setAttribute(WebKeys.MESSAGE_BOARDS_TREE_WALKER_THREAD, messageDisplay.getThread());

    return super.include(request, response, template);
  }
コード例 #3
0
  public static com.liferay.portlet.messageboards.model.MBMessageSoap addDiscussionMessage(
      long groupId,
      java.lang.String className,
      long classPK,
      java.lang.String permissionClassName,
      long permissionClassPK,
      long permissionOwnerId,
      long threadId,
      long parentMessageId,
      java.lang.String subject,
      java.lang.String body,
      com.liferay.portal.service.ServiceContext serviceContext)
      throws RemoteException {
    try {
      com.liferay.portlet.messageboards.model.MBMessage returnValue =
          MBMessageServiceUtil.addDiscussionMessage(
              groupId,
              className,
              classPK,
              permissionClassName,
              permissionClassPK,
              permissionOwnerId,
              threadId,
              parentMessageId,
              subject,
              body,
              serviceContext);

      return com.liferay.portlet.messageboards.model.MBMessageSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #4
0
  public static void unsubscribeMessage(long messageId) throws RemoteException {
    try {
      MBMessageServiceUtil.unsubscribeMessage(messageId);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #5
0
  public static void deleteMessageAttachments(long messageId) throws RemoteException {
    try {
      MBMessageServiceUtil.deleteMessageAttachments(messageId);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #6
0
  public static void updateAnswer(long messageId, boolean answer, boolean cascade)
      throws RemoteException {
    try {
      MBMessageServiceUtil.updateAnswer(messageId, answer, cascade);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #7
0
  public static int getGroupMessagesCount(long groupId, int status) throws RemoteException {
    try {
      int returnValue = MBMessageServiceUtil.getGroupMessagesCount(groupId, status);

      return returnValue;
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #8
0
  public static int getThreadAnswersCount(long groupId, long categoryId, long threadId)
      throws RemoteException {
    try {
      int returnValue = MBMessageServiceUtil.getThreadAnswersCount(groupId, categoryId, threadId);

      return returnValue;
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #9
0
  public static com.liferay.portlet.messageboards.model.MBMessageSoap getMessage(long messageId)
      throws RemoteException {
    try {
      com.liferay.portlet.messageboards.model.MBMessage returnValue =
          MBMessageServiceUtil.getMessage(messageId);

      return com.liferay.portlet.messageboards.model.MBMessageSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #10
0
  public static com.liferay.portlet.messageboards.model.MBMessageSoap[] getCategoryMessages(
      long groupId, long categoryId, int status, int start, int end) throws RemoteException {
    try {
      java.util.List<com.liferay.portlet.messageboards.model.MBMessage> returnValue =
          MBMessageServiceUtil.getCategoryMessages(groupId, categoryId, status, start, end);

      return com.liferay.portlet.messageboards.model.MBMessageSoap.toSoapModels(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #11
0
  public static com.liferay.portlet.messageboards.model.MBMessageSoap addMessage(
      long groupId,
      long categoryId,
      long threadId,
      long parentMessageId,
      java.lang.String subject,
      java.lang.String body,
      java.lang.String format,
      java.util.List<
              com.liferay.portal.kernel.util.ObjectValuePair<java.lang.String, java.io.InputStream>>
          inputStreamOVPs,
      boolean anonymous,
      double priority,
      boolean allowPingbacks,
      com.liferay.portal.service.ServiceContext serviceContext)
      throws RemoteException {
    try {
      com.liferay.portlet.messageboards.model.MBMessage returnValue =
          MBMessageServiceUtil.addMessage(
              groupId,
              categoryId,
              threadId,
              parentMessageId,
              subject,
              body,
              format,
              inputStreamOVPs,
              anonymous,
              priority,
              allowPingbacks,
              serviceContext);

      return com.liferay.portlet.messageboards.model.MBMessageSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #12
0
  public static void deleteDiscussionMessage(
      long groupId,
      java.lang.String className,
      long classPK,
      java.lang.String permissionClassName,
      long permissionClassPK,
      long permissionOwnerId,
      long messageId)
      throws RemoteException {
    try {
      MBMessageServiceUtil.deleteDiscussionMessage(
          groupId,
          className,
          classPK,
          permissionClassName,
          permissionClassPK,
          permissionOwnerId,
          messageId);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
コード例 #13
0
  public void deliver(String from, String recipient, Message message)
      throws MessageListenerException {

    try {
      StopWatch stopWatch = null;

      if (_log.isDebugEnabled()) {
        stopWatch = new StopWatch();

        stopWatch.start();

        _log.debug("Deliver message from " + from + " to " + recipient);
      }

      String messageId = getMessageId(recipient, message);

      Company company = getCompany(messageId);

      if (_log.isDebugEnabled()) {
        _log.debug("Message id " + messageId);
      }

      long groupId = 0;
      long categoryId = getCategoryId(messageId);

      try {
        MBCategory category = MBCategoryLocalServiceUtil.getCategory(categoryId);

        groupId = category.getGroupId();
      } catch (NoSuchCategoryException nsce) {
        groupId = categoryId;
        categoryId = MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID;
      }

      if (_log.isDebugEnabled()) {
        _log.debug("Group id " + groupId);
        _log.debug("Category id " + categoryId);
      }

      User user = UserLocalServiceUtil.getUserByEmailAddress(company.getCompanyId(), from);

      long parentMessageId = getParentMessageId(recipient, message);

      if (_log.isDebugEnabled()) {
        _log.debug("Parent message id " + parentMessageId);
      }

      MBMessage parentMessage = null;

      try {
        if (parentMessageId > 0) {
          parentMessage = MBMessageLocalServiceUtil.getMessage(parentMessageId);
        }
      } catch (NoSuchMessageException nsme) {

        // If the parent message does not exist we ignore it and post
        // the message as a new thread.

      }

      if (_log.isDebugEnabled()) {
        _log.debug("Parent message " + parentMessage);
      }

      String subject = MBUtil.getSubjectWithoutMessageId(message);

      MBMailMessage collector = new MBMailMessage();

      MBUtil.collectPartContent(message, collector);

      PermissionCheckerUtil.setThreadValues(user);

      ServiceContext serviceContext = new ServiceContext();

      serviceContext.setAddGroupPermissions(true);
      serviceContext.setAddGuestPermissions(true);
      serviceContext.setLayoutFullURL(
          PortalUtil.getLayoutFullURL(groupId, PortletKeys.MESSAGE_BOARDS));
      serviceContext.setScopeGroupId(groupId);

      if (parentMessage == null) {
        MBMessageServiceUtil.addMessage(
            groupId,
            categoryId,
            subject,
            collector.getBody(),
            MBMessageConstants.DEFAULT_FORMAT,
            collector.getFiles(),
            false,
            0.0,
            true,
            serviceContext);
      } else {
        MBMessageServiceUtil.addMessage(
            groupId,
            categoryId,
            parentMessage.getThreadId(),
            parentMessage.getMessageId(),
            subject,
            collector.getBody(),
            MBMessageConstants.DEFAULT_FORMAT,
            collector.getFiles(),
            false,
            0.0,
            true,
            serviceContext);
      }

      if (_log.isDebugEnabled()) {
        _log.debug("Delivering message takes " + stopWatch.getTime() + " ms");
      }
    } catch (PrincipalException pe) {
      if (_log.isDebugEnabled()) {
        _log.debug("Prevented unauthorized post from " + from);
      }

      throw new MessageListenerException(pe);
    } catch (Exception e) {
      _log.error(e, e);

      throw new MessageListenerException(e);
    } finally {
      PermissionCheckerUtil.setThreadValues(null);
    }
  }