コード例 #1
0
  public void synchronizePage(long folderId, int pageNumber, int messagesPerPage)
      throws PortalException, SystemException {

    long[] remoteMessageIds = _imapAccessor.getMessageUIDs(folderId, pageNumber, messagesPerPage);

    List<Long> missingRemoteMessageIdsList = new ArrayList<Long>();

    for (int i = 0; i < remoteMessageIds.length; i++) {
      long remoteMessageId = remoteMessageIds[i];

      try {
        MessageLocalServiceUtil.getMessage(folderId, remoteMessageId);
      } catch (NoSuchMessageException nsme) {
        missingRemoteMessageIdsList.add(remoteMessageId);
      }
    }

    if (!missingRemoteMessageIdsList.isEmpty()) {
      long[] missingRemoteMessageIds =
          ArrayUtil.toArray(
              missingRemoteMessageIdsList.toArray(new Long[missingRemoteMessageIdsList.size()]));

      _imapAccessor.storeEnvelopes(folderId, missingRemoteMessageIds);
    }
  }
コード例 #2
0
  public AttachmentHandler getAttachment(long attachmentId)
      throws IOException, PortalException, SystemException {

    Attachment attachment = AttachmentLocalServiceUtil.getAttachment(attachmentId);

    Message message = MessageLocalServiceUtil.getMessage(attachment.getMessageId());

    if (account.getDraftFolderId() == attachment.getFolderId()) {
      return new DefaultAttachmentHandler(
          AttachmentLocalServiceUtil.getInputStream(attachmentId), null);
    } else {
      return _imapAccessor.getAttachment(
          attachment.getFolderId(), message.getRemoteMessageId(), attachment.getContentPath());
    }
  }
コード例 #3
0
  public void synchronizeMessage(long messageId) throws PortalException, SystemException {

    Message message = MessageLocalServiceUtil.getMessage(messageId);

    long remoteMessageId = message.getRemoteMessageId();

    if (remoteMessageId == 0) {
      return;
    }

    try {
      _imapAccessor.storeContents(message.getFolderId(), new long[] {message.getRemoteMessageId()});
    } catch (IOException ioe) {
      throw new MailException(ioe);
    }
  }
コード例 #4
0
  public void moveMessages(long folderId, long[] messageIds)
      throws PortalException, SystemException {

    for (long messageId : messageIds) {
      Message message = MessageLocalServiceUtil.getMessage(messageId);

      Account account = AccountLocalServiceUtil.getAccount(message.getAccountId());

      long sourceFolderId = message.getFolderId();

      if ((account.getDraftFolderId() == sourceFolderId)
          || (account.getSentFolderId() == sourceFolderId)) {

        throw new MailException(MailException.FOLDER_INVALID_DESTINATION);
      }

      _imapAccessor.moveMessages(sourceFolderId, folderId, new long[] {messageId}, true);
    }
  }
コード例 #5
0
  public void sendMessage(long accountId, long messageId) throws PortalException, SystemException {

    Account account = AccountLocalServiceUtil.getAccount(accountId);

    Message message = MessageLocalServiceUtil.getMessage(messageId);

    Address[] toAddresses = parseAddresses(message.getTo());
    Address[] ccAddresses = parseAddresses(message.getCc());
    Address[] bccAddresses = parseAddresses(message.getBcc());

    if ((toAddresses.length == 0) && (ccAddresses.length == 0) && (bccAddresses.length == 0)) {

      throw new MailException(MailException.MESSAGE_HAS_NO_RECIPIENTS);
    }

    List<Attachment> attachments = AttachmentLocalServiceUtil.getAttachments(messageId);

    List<MailFile> mailFiles = new ArrayList<MailFile>();

    for (Attachment attachment : attachments) {
      File file = AttachmentLocalServiceUtil.getFile(attachment.getAttachmentId());

      MailFile mailFile = new MailFile(file, attachment.getFileName(), attachment.getSize());

      mailFiles.add(mailFile);
    }

    _imapAccessor.sendMessage(
        account.getPersonalName(),
        account.getAddress(),
        toAddresses,
        ccAddresses,
        bccAddresses,
        message.getSubject(),
        message.getBody(),
        mailFiles);

    MessageLocalServiceUtil.deleteMessage(messageId);
  }
コード例 #6
0
  public Object invokeMethod(String name, String[] parameterTypes, Object[] arguments)
      throws Throwable {
    if (_methodName0.equals(name) && Arrays.deepEquals(_methodParameterTypes0, parameterTypes)) {
      return MessageLocalServiceUtil.addMessage((com.liferay.mail.model.Message) arguments[0]);
    }

    if (_methodName1.equals(name) && Arrays.deepEquals(_methodParameterTypes1, parameterTypes)) {
      return MessageLocalServiceUtil.createMessage(((Long) arguments[0]).longValue());
    }

    if (_methodName2.equals(name) && Arrays.deepEquals(_methodParameterTypes2, parameterTypes)) {
      return MessageLocalServiceUtil.deleteMessage(((Long) arguments[0]).longValue());
    }

    if (_methodName3.equals(name) && Arrays.deepEquals(_methodParameterTypes3, parameterTypes)) {
      return MessageLocalServiceUtil.deleteMessage((com.liferay.mail.model.Message) arguments[0]);
    }

    if (_methodName4.equals(name) && Arrays.deepEquals(_methodParameterTypes4, parameterTypes)) {
      return MessageLocalServiceUtil.dynamicQuery();
    }

    if (_methodName5.equals(name) && Arrays.deepEquals(_methodParameterTypes5, parameterTypes)) {
      return MessageLocalServiceUtil.dynamicQuery(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0]);
    }

    if (_methodName6.equals(name) && Arrays.deepEquals(_methodParameterTypes6, parameterTypes)) {
      return MessageLocalServiceUtil.dynamicQuery(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0],
          ((Integer) arguments[1]).intValue(),
          ((Integer) arguments[2]).intValue());
    }

    if (_methodName7.equals(name) && Arrays.deepEquals(_methodParameterTypes7, parameterTypes)) {
      return MessageLocalServiceUtil.dynamicQuery(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0],
          ((Integer) arguments[1]).intValue(),
          ((Integer) arguments[2]).intValue(),
          (com.liferay.portal.kernel.util.OrderByComparator) arguments[3]);
    }

    if (_methodName8.equals(name) && Arrays.deepEquals(_methodParameterTypes8, parameterTypes)) {
      return MessageLocalServiceUtil.dynamicQueryCount(
          (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0]);
    }

    if (_methodName9.equals(name) && Arrays.deepEquals(_methodParameterTypes9, parameterTypes)) {
      return MessageLocalServiceUtil.fetchMessage(((Long) arguments[0]).longValue());
    }

    if (_methodName10.equals(name) && Arrays.deepEquals(_methodParameterTypes10, parameterTypes)) {
      return MessageLocalServiceUtil.getMessage(((Long) arguments[0]).longValue());
    }

    if (_methodName11.equals(name) && Arrays.deepEquals(_methodParameterTypes11, parameterTypes)) {
      return MessageLocalServiceUtil.getPersistedModel((java.io.Serializable) arguments[0]);
    }

    if (_methodName12.equals(name) && Arrays.deepEquals(_methodParameterTypes12, parameterTypes)) {
      return MessageLocalServiceUtil.getMessages(
          ((Integer) arguments[0]).intValue(), ((Integer) arguments[1]).intValue());
    }

    if (_methodName13.equals(name) && Arrays.deepEquals(_methodParameterTypes13, parameterTypes)) {
      return MessageLocalServiceUtil.getMessagesCount();
    }

    if (_methodName14.equals(name) && Arrays.deepEquals(_methodParameterTypes14, parameterTypes)) {
      return MessageLocalServiceUtil.updateMessage((com.liferay.mail.model.Message) arguments[0]);
    }

    if (_methodName43.equals(name) && Arrays.deepEquals(_methodParameterTypes43, parameterTypes)) {
      return MessageLocalServiceUtil.getBeanIdentifier();
    }

    if (_methodName44.equals(name) && Arrays.deepEquals(_methodParameterTypes44, parameterTypes)) {
      MessageLocalServiceUtil.setBeanIdentifier((java.lang.String) arguments[0]);

      return null;
    }

    if (_methodName49.equals(name) && Arrays.deepEquals(_methodParameterTypes49, parameterTypes)) {
      return MessageLocalServiceUtil.addMessage(
          ((Long) arguments[0]).longValue(),
          ((Long) arguments[1]).longValue(),
          (java.lang.String) arguments[2],
          (java.lang.String) arguments[3],
          (java.lang.String) arguments[4],
          (java.lang.String) arguments[5],
          (java.util.Date) arguments[6],
          (java.lang.String) arguments[7],
          (java.lang.String) arguments[8],
          (java.lang.String) arguments[9],
          ((Long) arguments[10]).longValue());
    }

    if (_methodName50.equals(name) && Arrays.deepEquals(_methodParameterTypes50, parameterTypes)) {
      return MessageLocalServiceUtil.deleteMessage(((Long) arguments[0]).longValue());
    }

    if (_methodName51.equals(name) && Arrays.deepEquals(_methodParameterTypes51, parameterTypes)) {
      return MessageLocalServiceUtil.deleteMessage((com.liferay.mail.model.Message) arguments[0]);
    }

    if (_methodName52.equals(name) && Arrays.deepEquals(_methodParameterTypes52, parameterTypes)) {
      MessageLocalServiceUtil.deleteMessages(((Long) arguments[0]).longValue());

      return null;
    }

    if (_methodName53.equals(name) && Arrays.deepEquals(_methodParameterTypes53, parameterTypes)) {
      return MessageLocalServiceUtil.getAccountUnreadMessagesCount(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName54.equals(name) && Arrays.deepEquals(_methodParameterTypes54, parameterTypes)) {
      return MessageLocalServiceUtil.getCompanyMessages(
          ((Long) arguments[0]).longValue(),
          ((Integer) arguments[1]).intValue(),
          ((Integer) arguments[2]).intValue());
    }

    if (_methodName55.equals(name) && Arrays.deepEquals(_methodParameterTypes55, parameterTypes)) {
      return MessageLocalServiceUtil.getCompanyMessagesCount(((Long) arguments[0]).longValue());
    }

    if (_methodName56.equals(name) && Arrays.deepEquals(_methodParameterTypes56, parameterTypes)) {
      return MessageLocalServiceUtil.getFolderMessages(((Long) arguments[0]).longValue());
    }

    if (_methodName57.equals(name) && Arrays.deepEquals(_methodParameterTypes57, parameterTypes)) {
      return MessageLocalServiceUtil.getFolderMessagesCount(((Long) arguments[0]).longValue());
    }

    if (_methodName58.equals(name) && Arrays.deepEquals(_methodParameterTypes58, parameterTypes)) {
      return MessageLocalServiceUtil.getFolderUnreadMessagesCount(
          ((Long) arguments[0]).longValue());
    }

    if (_methodName59.equals(name) && Arrays.deepEquals(_methodParameterTypes59, parameterTypes)) {
      return MessageLocalServiceUtil.getMessage(
          ((Long) arguments[0]).longValue(), ((Long) arguments[1]).longValue());
    }

    if (_methodName60.equals(name) && Arrays.deepEquals(_methodParameterTypes60, parameterTypes)) {
      return MessageLocalServiceUtil.getRemoteMessage(
          ((Long) arguments[0]).longValue(), ((Boolean) arguments[1]).booleanValue());
    }

    if (_methodName61.equals(name) && Arrays.deepEquals(_methodParameterTypes61, parameterTypes)) {
      return MessageLocalServiceUtil.populateMessages(
          (java.util.List<com.liferay.mail.model.Message>) arguments[0],
          ((Long) arguments[1]).longValue(),
          (java.lang.String) arguments[2],
          ((Integer) arguments[3]).intValue(),
          ((Integer) arguments[4]).intValue(),
          (java.lang.String) arguments[5],
          (java.lang.String) arguments[6]);
    }

    if (_methodName62.equals(name) && Arrays.deepEquals(_methodParameterTypes62, parameterTypes)) {
      return MessageLocalServiceUtil.updateContent(
          ((Long) arguments[0]).longValue(),
          (java.lang.String) arguments[1],
          (java.lang.String) arguments[2]);
    }

    if (_methodName63.equals(name) && Arrays.deepEquals(_methodParameterTypes63, parameterTypes)) {
      return MessageLocalServiceUtil.updateFlag(
          ((Long) arguments[0]).longValue(),
          ((Integer) arguments[1]).intValue(),
          ((Boolean) arguments[2]).booleanValue());
    }

    if (_methodName64.equals(name) && Arrays.deepEquals(_methodParameterTypes64, parameterTypes)) {
      return MessageLocalServiceUtil.updateMessage(
          ((Long) arguments[0]).longValue(),
          ((Long) arguments[1]).longValue(),
          (java.lang.String) arguments[2],
          (java.lang.String) arguments[3],
          (java.lang.String) arguments[4],
          (java.lang.String) arguments[5],
          (java.util.Date) arguments[6],
          (java.lang.String) arguments[7],
          (java.lang.String) arguments[8],
          (java.lang.String) arguments[9],
          ((Long) arguments[10]).longValue());
    }

    throw new UnsupportedOperationException();
  }
コード例 #7
0
  @Override
  protected void doReindex(String className, long classPK) throws Exception {
    Message message = MessageLocalServiceUtil.getMessage(classPK);

    doReindex(message);
  }