protected JournalFeed addJournalFeed() throws Exception {
    long pk = nextLong();

    JournalFeed journalFeed = _persistence.create(pk);

    journalFeed.setUuid(randomString());
    journalFeed.setGroupId(nextLong());
    journalFeed.setCompanyId(nextLong());
    journalFeed.setUserId(nextLong());
    journalFeed.setUserName(randomString());
    journalFeed.setCreateDate(nextDate());
    journalFeed.setModifiedDate(nextDate());
    journalFeed.setFeedId(randomString());
    journalFeed.setName(randomString());
    journalFeed.setDescription(randomString());
    journalFeed.setType(randomString());
    journalFeed.setStructureId(randomString());
    journalFeed.setTemplateId(randomString());
    journalFeed.setRendererTemplateId(randomString());
    journalFeed.setDelta(nextInt());
    journalFeed.setOrderByCol(randomString());
    journalFeed.setOrderByType(randomString());
    journalFeed.setTargetLayoutFriendlyUrl(randomString());
    journalFeed.setTargetPortletId(randomString());
    journalFeed.setContentField(randomString());
    journalFeed.setFeedType(randomString());
    journalFeed.setFeedVersion(nextDouble());

    _persistence.update(journalFeed, false);

    return journalFeed;
  }
コード例 #2
0
  public JournalFeed updateFeed(
      long groupId,
      String feedId,
      String name,
      String description,
      String type,
      String structureId,
      String templateId,
      String rendererTemplateId,
      int delta,
      String orderByCol,
      String orderByType,
      String targetLayoutFriendlyUrl,
      String targetPortletId,
      String contentField,
      String feedType,
      double feedVersion,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Feed

    JournalFeed feed = journalFeedPersistence.findByG_F(groupId, feedId);

    validate(
        feed.getCompanyId(), groupId, name, structureId, targetLayoutFriendlyUrl, contentField);

    feed.setModifiedDate(serviceContext.getModifiedDate(null));
    feed.setName(name);
    feed.setDescription(description);
    feed.setType(type);
    feed.setStructureId(structureId);
    feed.setTemplateId(templateId);
    feed.setRendererTemplateId(rendererTemplateId);
    feed.setDelta(delta);
    feed.setOrderByCol(orderByCol);
    feed.setOrderByType(orderByType);
    feed.setTargetLayoutFriendlyUrl(targetLayoutFriendlyUrl);
    feed.setTargetPortletId(targetPortletId);
    feed.setContentField(contentField);

    if (Validator.isNull(feedType)) {
      feed.setFeedType(RSSUtil.TYPE_DEFAULT);
      feed.setFeedVersion(RSSUtil.VERSION_DEFAULT);
    } else {
      feed.setFeedType(feedType);
      feed.setFeedVersion(feedVersion);
    }

    journalFeedPersistence.update(feed, false);

    // Expando

    ExpandoBridge expandoBridge = feed.getExpandoBridge();

    expandoBridge.setAttributes(serviceContext);

    return feed;
  }
  public void testUpdateExisting() throws Exception {
    long pk = nextLong();

    JournalFeed newJournalFeed = _persistence.create(pk);

    newJournalFeed.setUuid(randomString());
    newJournalFeed.setGroupId(nextLong());
    newJournalFeed.setCompanyId(nextLong());
    newJournalFeed.setUserId(nextLong());
    newJournalFeed.setUserName(randomString());
    newJournalFeed.setCreateDate(nextDate());
    newJournalFeed.setModifiedDate(nextDate());
    newJournalFeed.setFeedId(randomString());
    newJournalFeed.setName(randomString());
    newJournalFeed.setDescription(randomString());
    newJournalFeed.setType(randomString());
    newJournalFeed.setStructureId(randomString());
    newJournalFeed.setTemplateId(randomString());
    newJournalFeed.setRendererTemplateId(randomString());
    newJournalFeed.setDelta(nextInt());
    newJournalFeed.setOrderByCol(randomString());
    newJournalFeed.setOrderByType(randomString());
    newJournalFeed.setTargetLayoutFriendlyUrl(randomString());
    newJournalFeed.setTargetPortletId(randomString());
    newJournalFeed.setContentField(randomString());
    newJournalFeed.setFeedType(randomString());
    newJournalFeed.setFeedVersion(nextDouble());

    _persistence.update(newJournalFeed, false);

    JournalFeed existingJournalFeed = _persistence.findByPrimaryKey(newJournalFeed.getPrimaryKey());

    assertEquals(existingJournalFeed.getUuid(), newJournalFeed.getUuid());
    assertEquals(existingJournalFeed.getId(), newJournalFeed.getId());
    assertEquals(existingJournalFeed.getGroupId(), newJournalFeed.getGroupId());
    assertEquals(existingJournalFeed.getCompanyId(), newJournalFeed.getCompanyId());
    assertEquals(existingJournalFeed.getUserId(), newJournalFeed.getUserId());
    assertEquals(existingJournalFeed.getUserName(), newJournalFeed.getUserName());
    assertEquals(
        Time.getShortTimestamp(existingJournalFeed.getCreateDate()),
        Time.getShortTimestamp(newJournalFeed.getCreateDate()));
    assertEquals(
        Time.getShortTimestamp(existingJournalFeed.getModifiedDate()),
        Time.getShortTimestamp(newJournalFeed.getModifiedDate()));
    assertEquals(existingJournalFeed.getFeedId(), newJournalFeed.getFeedId());
    assertEquals(existingJournalFeed.getName(), newJournalFeed.getName());
    assertEquals(existingJournalFeed.getDescription(), newJournalFeed.getDescription());
    assertEquals(existingJournalFeed.getType(), newJournalFeed.getType());
    assertEquals(existingJournalFeed.getStructureId(), newJournalFeed.getStructureId());
    assertEquals(existingJournalFeed.getTemplateId(), newJournalFeed.getTemplateId());
    assertEquals(
        existingJournalFeed.getRendererTemplateId(), newJournalFeed.getRendererTemplateId());
    assertEquals(existingJournalFeed.getDelta(), newJournalFeed.getDelta());
    assertEquals(existingJournalFeed.getOrderByCol(), newJournalFeed.getOrderByCol());
    assertEquals(existingJournalFeed.getOrderByType(), newJournalFeed.getOrderByType());
    assertEquals(
        existingJournalFeed.getTargetLayoutFriendlyUrl(),
        newJournalFeed.getTargetLayoutFriendlyUrl());
    assertEquals(existingJournalFeed.getTargetPortletId(), newJournalFeed.getTargetPortletId());
    assertEquals(existingJournalFeed.getContentField(), newJournalFeed.getContentField());
    assertEquals(existingJournalFeed.getFeedType(), newJournalFeed.getFeedType());
    assertEquals(existingJournalFeed.getFeedVersion(), newJournalFeed.getFeedVersion());
  }
コード例 #4
0
  @Override
  public JournalFeed addFeed(
      long userId,
      long groupId,
      String feedId,
      boolean autoFeedId,
      String name,
      String description,
      String type,
      String structureId,
      String templateId,
      String rendererTemplateId,
      int delta,
      String orderByCol,
      String orderByType,
      String targetLayoutFriendlyUrl,
      String targetPortletId,
      String contentField,
      String feedFormat,
      double feedVersion,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Feed

    User user = userPersistence.findByPrimaryKey(userId);
    feedId = StringUtil.toUpperCase(feedId.trim());
    Date now = new Date();

    validate(
        user.getCompanyId(),
        groupId,
        feedId,
        autoFeedId,
        name,
        structureId,
        targetLayoutFriendlyUrl,
        contentField);

    if (autoFeedId) {
      feedId = String.valueOf(counterLocalService.increment());
    }

    long id = counterLocalService.increment();

    JournalFeed feed = journalFeedPersistence.create(id);

    feed.setUuid(serviceContext.getUuid());
    feed.setGroupId(groupId);
    feed.setCompanyId(user.getCompanyId());
    feed.setUserId(user.getUserId());
    feed.setUserName(user.getFullName());
    feed.setCreateDate(serviceContext.getCreateDate(now));
    feed.setModifiedDate(serviceContext.getModifiedDate(now));
    feed.setFeedId(feedId);
    feed.setName(name);
    feed.setDescription(description);
    feed.setType(type);
    feed.setStructureId(structureId);
    feed.setTemplateId(templateId);
    feed.setRendererTemplateId(rendererTemplateId);
    feed.setDelta(delta);
    feed.setOrderByCol(orderByCol);
    feed.setOrderByType(orderByType);
    feed.setTargetLayoutFriendlyUrl(targetLayoutFriendlyUrl);
    feed.setTargetPortletId(targetPortletId);
    feed.setContentField(contentField);

    if (Validator.isNull(feedFormat)) {
      feed.setFeedFormat(RSSUtil.FORMAT_DEFAULT);
      feed.setFeedVersion(RSSUtil.VERSION_DEFAULT);
    } else {
      feed.setFeedFormat(feedFormat);
      feed.setFeedVersion(feedVersion);
    }

    feed.setExpandoBridgeAttributes(serviceContext);

    journalFeedPersistence.update(feed);

    // Resources

    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {

      addFeedResources(
          feed, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions());
    } else {
      addFeedResources(
          feed, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }

    return feed;
  }