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();
  }
Exemplo n.º 2
0
  public Message saveDraft(
      long accountId,
      long messageId,
      String to,
      String cc,
      String bcc,
      String subject,
      String body,
      List<MailFile> mailFiles)
      throws PortalException, SystemException {

    Account account = AccountLocalServiceUtil.getAccount(accountId);

    StringBundler sb = new StringBundler();

    sb.append(user.getFullName());
    sb.append(" <");
    sb.append(account.getAddress());
    sb.append(StringPool.GREATER_THAN);

    String sender = sb.toString();

    Address[] toAddresses = parseAddresses(to);
    Address[] ccAddresses = parseAddresses(cc);
    Address[] bccAddresses = parseAddresses(bcc);

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

      throw new MailException(MailException.MESSAGE_HAS_NO_RECIPIENTS);
    }

    Message message = null;

    if (messageId != 0) {
      message =
          MessageLocalServiceUtil.updateMessage(
              messageId,
              account.getDraftFolderId(),
              sender,
              InternetAddressUtil.toString(toAddresses),
              InternetAddressUtil.toString(ccAddresses),
              InternetAddressUtil.toString(bccAddresses),
              null,
              subject,
              body,
              String.valueOf(MailConstants.FLAG_DRAFT),
              0);
    } else {
      message =
          MessageLocalServiceUtil.addMessage(
              user.getUserId(),
              account.getDraftFolderId(),
              sender,
              to,
              cc,
              bcc,
              null,
              subject,
              body,
              String.valueOf(MailConstants.FLAG_DRAFT),
              0);
    }

    if (mailFiles == null) {
      return message;
    }

    for (MailFile mailFile : mailFiles) {
      AttachmentLocalServiceUtil.addAttachment(
          user.getUserId(),
          message.getMessageId(),
          null,
          mailFile.getFileName(),
          mailFile.getSize(),
          mailFile.getFile());
    }

    return message;
  }