コード例 #1
0
  public static String getMailingListAddress(
      long groupId, long categoryId, long messageId, String mx, String defaultMailingListAddress) {

    if (PropsValues.POP_SERVER_SUBDOMAIN.length() <= 0) {
      String mailingListAddress = defaultMailingListAddress;

      try {
        MBMailingList mailingList =
            MBMailingListLocalServiceUtil.getCategoryMailingList(groupId, categoryId);

        if (mailingList.isActive()) {
          mailingListAddress = mailingList.getEmailAddress();
        }
      } catch (Exception e) {
      }

      return mailingListAddress;
    }

    StringBundler sb = new StringBundler(8);

    sb.append(MESSAGE_POP_PORTLET_PREFIX);
    sb.append(categoryId);
    sb.append(StringPool.PERIOD);
    sb.append(messageId);
    sb.append(StringPool.AT);
    sb.append(PropsValues.POP_SERVER_SUBDOMAIN);
    sb.append(StringPool.PERIOD);
    sb.append(mx);

    return sb.toString();
  }
コード例 #2
0
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    MBMailingList newMBMailingList = addMBMailingList();

    _persistence.clearCache();

    MBMailingListModelImpl existingMBMailingListModelImpl =
        (MBMailingListModelImpl) _persistence.findByPrimaryKey(newMBMailingList.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingMBMailingListModelImpl.getUuid(),
            existingMBMailingListModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingMBMailingListModelImpl.getGroupId(),
        existingMBMailingListModelImpl.getOriginalGroupId());

    Assert.assertEquals(
        existingMBMailingListModelImpl.getGroupId(),
        existingMBMailingListModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingMBMailingListModelImpl.getCategoryId(),
        existingMBMailingListModelImpl.getOriginalCategoryId());
  }
コード例 #3
0
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    MBMailingList newMBMailingList = addMBMailingList();

    MBMailingList existingMBMailingList =
        _persistence.fetchByPrimaryKey(newMBMailingList.getPrimaryKey());

    Assert.assertEquals(existingMBMailingList, newMBMailingList);
  }
コード例 #4
0
  @Test
  public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBMailingList mbMailingList = _persistence.create(pk);

    Assert.assertNotNull(mbMailingList);

    Assert.assertEquals(mbMailingList.getPrimaryKey(), pk);
  }
コード例 #5
0
  @Test
  public void testRemove() throws Exception {
    MBMailingList newMBMailingList = addMBMailingList();

    _persistence.remove(newMBMailingList);

    MBMailingList existingMBMailingList =
        _persistence.fetchByPrimaryKey(newMBMailingList.getPrimaryKey());

    Assert.assertNull(existingMBMailingList);
  }
コード例 #6
0
  @Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    MBMailingList newMBMailingList = addMBMailingList();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newMBMailingList.getPrimaryKey());

    Map<Serializable, MBMailingList> mbMailingLists = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, mbMailingLists.size());
    Assert.assertEquals(newMBMailingList, mbMailingLists.get(newMBMailingList.getPrimaryKey()));
  }
コード例 #7
0
  /**
   * Adds the message boards mailing list to the database. Also notifies the appropriate model
   * listeners.
   *
   * @param mbMailingList the message boards mailing list
   * @return the message boards mailing list that was added
   * @throws SystemException if a system exception occurred
   */
  @Indexable(type = IndexableType.REINDEX)
  @Override
  public MBMailingList addMBMailingList(MBMailingList mbMailingList) throws SystemException {
    mbMailingList.setNew(true);

    return mbMailingListPersistence.update(mbMailingList);
  }
コード例 #8
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    MBMailingList newMBMailingList = addMBMailingList();

    long pk = RandomTestUtil.nextLong();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newMBMailingList.getPrimaryKey());
    primaryKeys.add(pk);

    Map<Serializable, MBMailingList> mbMailingLists = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, mbMailingLists.size());
    Assert.assertEquals(newMBMailingList, mbMailingLists.get(newMBMailingList.getPrimaryKey()));
  }
コード例 #9
0
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    MBMailingList newMBMailingList = addMBMailingList();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(MBMailingList.class, _dynamicQueryClassLoader);

    dynamicQuery.add(
        RestrictionsFactoryUtil.eq("mailingListId", newMBMailingList.getMailingListId()));

    List<MBMailingList> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    MBMailingList existingMBMailingList = result.get(0);

    Assert.assertEquals(existingMBMailingList, newMBMailingList);
  }
コード例 #10
0
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    MBMailingList newMBMailingList = addMBMailingList();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(MBMailingList.class, _dynamicQueryClassLoader);

    dynamicQuery.setProjection(ProjectionFactoryUtil.property("mailingListId"));

    Object newMailingListId = newMBMailingList.getMailingListId();

    dynamicQuery.add(RestrictionsFactoryUtil.in("mailingListId", new Object[] {newMailingListId}));

    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    Object existingMailingListId = result.get(0);

    Assert.assertEquals(existingMailingListId, newMailingListId);
  }
コード例 #11
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    MBMailingList newMBMailingList1 = addMBMailingList();
    MBMailingList newMBMailingList2 = addMBMailingList();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newMBMailingList1.getPrimaryKey());
    primaryKeys.add(newMBMailingList2.getPrimaryKey());

    Map<Serializable, MBMailingList> mbMailingLists = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, mbMailingLists.size());
    Assert.assertEquals(newMBMailingList1, mbMailingLists.get(newMBMailingList1.getPrimaryKey()));
    Assert.assertEquals(newMBMailingList2, mbMailingLists.get(newMBMailingList2.getPrimaryKey()));
  }
コード例 #12
0
  @Test
  public void testResetOriginalValues() throws Exception {
    MBMailingList newMBMailingList = addMBMailingList();

    _persistence.clearCache();

    MBMailingList existingMBMailingList =
        _persistence.findByPrimaryKey(newMBMailingList.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingMBMailingList.getUuid(),
            ReflectionTestUtil.invoke(existingMBMailingList, "getOriginalUuid", new Class<?>[0])));
    Assert.assertEquals(
        existingMBMailingList.getGroupId(),
        ReflectionTestUtil.invoke(existingMBMailingList, "getOriginalGroupId", new Class<?>[0]));

    Assert.assertEquals(
        existingMBMailingList.getGroupId(),
        ReflectionTestUtil.invoke(existingMBMailingList, "getOriginalGroupId", new Class<?>[0]));
    Assert.assertEquals(
        existingMBMailingList.getCategoryId(),
        ReflectionTestUtil.invoke(existingMBMailingList, "getOriginalCategoryId", new Class<?>[0]));
  }
コード例 #13
0
  @Override
  public MBCategory updateCategory(
      long categoryId,
      long parentCategoryId,
      String name,
      String description,
      String displayStyle,
      String emailAddress,
      String inProtocol,
      String inServerName,
      int inServerPort,
      boolean inUseSSL,
      String inUserName,
      String inPassword,
      int inReadInterval,
      String outEmailAddress,
      boolean outCustom,
      String outServerName,
      int outServerPort,
      boolean outUseSSL,
      String outUserName,
      String outPassword,
      boolean allowAnonymous,
      boolean mailingListActive,
      boolean mergeWithParentCategory,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Merge categories

    if ((categoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID)
        || (categoryId == MBCategoryConstants.DISCUSSION_CATEGORY_ID)) {

      return null;
    }

    MBCategory category = mbCategoryPersistence.findByPrimaryKey(categoryId);

    parentCategoryId = getParentCategoryId(category, parentCategoryId);

    if (mergeWithParentCategory
        && (categoryId != parentCategoryId)
        && (parentCategoryId != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID)
        && (parentCategoryId != MBCategoryConstants.DISCUSSION_CATEGORY_ID)) {

      mergeCategories(category, parentCategoryId);

      return category;
    }

    // Category

    validate(name);

    category.setModifiedDate(serviceContext.getModifiedDate(null));
    category.setParentCategoryId(parentCategoryId);
    category.setName(name);
    category.setDescription(description);

    if (!displayStyle.equals(category.getDisplayStyle())) {
      category.setDisplayStyle(displayStyle);

      updateChildCategoriesDisplayStyle(category, displayStyle);
    }

    category.setExpandoBridgeAttributes(serviceContext);

    mbCategoryPersistence.update(category);

    // Mailing list

    MBMailingList mailingList =
        mbMailingListPersistence.fetchByG_C(category.getGroupId(), category.getCategoryId());

    if (mailingList != null) {
      mbMailingListLocalService.updateMailingList(
          mailingList.getMailingListId(),
          emailAddress,
          inProtocol,
          inServerName,
          inServerPort,
          inUseSSL,
          inUserName,
          inPassword,
          inReadInterval,
          outEmailAddress,
          outCustom,
          outServerName,
          outServerPort,
          outUseSSL,
          outUserName,
          outPassword,
          allowAnonymous,
          mailingListActive,
          serviceContext);
    } else {
      mbMailingListLocalService.addMailingList(
          category.getUserId(),
          category.getGroupId(),
          category.getCategoryId(),
          emailAddress,
          inProtocol,
          inServerName,
          inServerPort,
          inUseSSL,
          inUserName,
          inPassword,
          inReadInterval,
          outEmailAddress,
          outCustom,
          outServerName,
          outServerPort,
          outUseSSL,
          outUserName,
          outPassword,
          allowAnonymous,
          mailingListActive,
          serviceContext);
    }

    return category;
  }
コード例 #14
0
  protected MBMailingList addMBMailingList() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBMailingList mbMailingList = _persistence.create(pk);

    mbMailingList.setUuid(RandomTestUtil.randomString());

    mbMailingList.setGroupId(RandomTestUtil.nextLong());

    mbMailingList.setCompanyId(RandomTestUtil.nextLong());

    mbMailingList.setUserId(RandomTestUtil.nextLong());

    mbMailingList.setUserName(RandomTestUtil.randomString());

    mbMailingList.setCreateDate(RandomTestUtil.nextDate());

    mbMailingList.setModifiedDate(RandomTestUtil.nextDate());

    mbMailingList.setCategoryId(RandomTestUtil.nextLong());

    mbMailingList.setEmailAddress(RandomTestUtil.randomString());

    mbMailingList.setInProtocol(RandomTestUtil.randomString());

    mbMailingList.setInServerName(RandomTestUtil.randomString());

    mbMailingList.setInServerPort(RandomTestUtil.nextInt());

    mbMailingList.setInUseSSL(RandomTestUtil.randomBoolean());

    mbMailingList.setInUserName(RandomTestUtil.randomString());

    mbMailingList.setInPassword(RandomTestUtil.randomString());

    mbMailingList.setInReadInterval(RandomTestUtil.nextInt());

    mbMailingList.setOutEmailAddress(RandomTestUtil.randomString());

    mbMailingList.setOutCustom(RandomTestUtil.randomBoolean());

    mbMailingList.setOutServerName(RandomTestUtil.randomString());

    mbMailingList.setOutServerPort(RandomTestUtil.nextInt());

    mbMailingList.setOutUseSSL(RandomTestUtil.randomBoolean());

    mbMailingList.setOutUserName(RandomTestUtil.randomString());

    mbMailingList.setOutPassword(RandomTestUtil.randomString());

    mbMailingList.setAllowAnonymous(RandomTestUtil.randomBoolean());

    mbMailingList.setActive(RandomTestUtil.randomBoolean());

    _mbMailingLists.add(_persistence.update(mbMailingList));

    return mbMailingList;
  }
コード例 #15
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBMailingList newMBMailingList = _persistence.create(pk);

    newMBMailingList.setUuid(RandomTestUtil.randomString());

    newMBMailingList.setGroupId(RandomTestUtil.nextLong());

    newMBMailingList.setCompanyId(RandomTestUtil.nextLong());

    newMBMailingList.setUserId(RandomTestUtil.nextLong());

    newMBMailingList.setUserName(RandomTestUtil.randomString());

    newMBMailingList.setCreateDate(RandomTestUtil.nextDate());

    newMBMailingList.setModifiedDate(RandomTestUtil.nextDate());

    newMBMailingList.setCategoryId(RandomTestUtil.nextLong());

    newMBMailingList.setEmailAddress(RandomTestUtil.randomString());

    newMBMailingList.setInProtocol(RandomTestUtil.randomString());

    newMBMailingList.setInServerName(RandomTestUtil.randomString());

    newMBMailingList.setInServerPort(RandomTestUtil.nextInt());

    newMBMailingList.setInUseSSL(RandomTestUtil.randomBoolean());

    newMBMailingList.setInUserName(RandomTestUtil.randomString());

    newMBMailingList.setInPassword(RandomTestUtil.randomString());

    newMBMailingList.setInReadInterval(RandomTestUtil.nextInt());

    newMBMailingList.setOutEmailAddress(RandomTestUtil.randomString());

    newMBMailingList.setOutCustom(RandomTestUtil.randomBoolean());

    newMBMailingList.setOutServerName(RandomTestUtil.randomString());

    newMBMailingList.setOutServerPort(RandomTestUtil.nextInt());

    newMBMailingList.setOutUseSSL(RandomTestUtil.randomBoolean());

    newMBMailingList.setOutUserName(RandomTestUtil.randomString());

    newMBMailingList.setOutPassword(RandomTestUtil.randomString());

    newMBMailingList.setAllowAnonymous(RandomTestUtil.randomBoolean());

    newMBMailingList.setActive(RandomTestUtil.randomBoolean());

    _mbMailingLists.add(_persistence.update(newMBMailingList));

    MBMailingList existingMBMailingList =
        _persistence.findByPrimaryKey(newMBMailingList.getPrimaryKey());

    Assert.assertEquals(existingMBMailingList.getUuid(), newMBMailingList.getUuid());
    Assert.assertEquals(
        existingMBMailingList.getMailingListId(), newMBMailingList.getMailingListId());
    Assert.assertEquals(existingMBMailingList.getGroupId(), newMBMailingList.getGroupId());
    Assert.assertEquals(existingMBMailingList.getCompanyId(), newMBMailingList.getCompanyId());
    Assert.assertEquals(existingMBMailingList.getUserId(), newMBMailingList.getUserId());
    Assert.assertEquals(existingMBMailingList.getUserName(), newMBMailingList.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingMBMailingList.getCreateDate()),
        Time.getShortTimestamp(newMBMailingList.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingMBMailingList.getModifiedDate()),
        Time.getShortTimestamp(newMBMailingList.getModifiedDate()));
    Assert.assertEquals(existingMBMailingList.getCategoryId(), newMBMailingList.getCategoryId());
    Assert.assertEquals(
        existingMBMailingList.getEmailAddress(), newMBMailingList.getEmailAddress());
    Assert.assertEquals(existingMBMailingList.getInProtocol(), newMBMailingList.getInProtocol());
    Assert.assertEquals(
        existingMBMailingList.getInServerName(), newMBMailingList.getInServerName());
    Assert.assertEquals(
        existingMBMailingList.getInServerPort(), newMBMailingList.getInServerPort());
    Assert.assertEquals(existingMBMailingList.getInUseSSL(), newMBMailingList.getInUseSSL());
    Assert.assertEquals(existingMBMailingList.getInUserName(), newMBMailingList.getInUserName());
    Assert.assertEquals(existingMBMailingList.getInPassword(), newMBMailingList.getInPassword());
    Assert.assertEquals(
        existingMBMailingList.getInReadInterval(), newMBMailingList.getInReadInterval());
    Assert.assertEquals(
        existingMBMailingList.getOutEmailAddress(), newMBMailingList.getOutEmailAddress());
    Assert.assertEquals(existingMBMailingList.getOutCustom(), newMBMailingList.getOutCustom());
    Assert.assertEquals(
        existingMBMailingList.getOutServerName(), newMBMailingList.getOutServerName());
    Assert.assertEquals(
        existingMBMailingList.getOutServerPort(), newMBMailingList.getOutServerPort());
    Assert.assertEquals(existingMBMailingList.getOutUseSSL(), newMBMailingList.getOutUseSSL());
    Assert.assertEquals(existingMBMailingList.getOutUserName(), newMBMailingList.getOutUserName());
    Assert.assertEquals(existingMBMailingList.getOutPassword(), newMBMailingList.getOutPassword());
    Assert.assertEquals(
        existingMBMailingList.getAllowAnonymous(), newMBMailingList.getAllowAnonymous());
    Assert.assertEquals(existingMBMailingList.getActive(), newMBMailingList.getActive());
  }