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 addFeedResources(
      JournalFeed feed, String[] groupPermissions, String[] guestPermissions)
      throws PortalException, SystemException {

    resourceLocalService.addModelResources(
        feed.getCompanyId(),
        feed.getGroupId(),
        feed.getUserId(),
        JournalFeed.class.getName(),
        feed.getId(),
        groupPermissions,
        guestPermissions);
  }
  public void addFeedResources(
      JournalFeed feed, boolean addGroupPermissions, boolean addGuestPermissions)
      throws PortalException, SystemException {

    resourceLocalService.addResources(
        feed.getCompanyId(),
        feed.getGroupId(),
        feed.getUserId(),
        JournalFeed.class.getName(),
        feed.getId(),
        false,
        addGroupPermissions,
        addGuestPermissions);
  }
  public void deleteFeed(JournalFeed feed) throws PortalException, SystemException {

    // Expando

    expandoValueLocalService.deleteValues(JournalFeed.class.getName(), feed.getId());

    // Resources

    resourceLocalService.deleteResource(
        feed.getCompanyId(),
        JournalFeed.class.getName(),
        ResourceConstants.SCOPE_INDIVIDUAL,
        feed.getId());

    // Feed

    journalFeedPersistence.remove(feed);
  }
Ejemplo n.º 5
0
  protected String getEntryURL(
      ResourceRequest resourceRequest,
      JournalFeed feed,
      JournalArticle article,
      Layout layout,
      ThemeDisplay themeDisplay)
      throws Exception {

    List<Long> hitLayoutIds =
        JournalContentSearchLocalServiceUtil.getLayoutIds(
            layout.getGroupId(), layout.isPrivateLayout(), article.getArticleId());

    if (hitLayoutIds.size() > 0) {
      Long hitLayoutId = hitLayoutIds.get(0);

      Layout hitLayout =
          LayoutLocalServiceUtil.getLayout(
              layout.getGroupId(), layout.isPrivateLayout(), hitLayoutId.longValue());

      return PortalUtil.getLayoutFriendlyURL(hitLayout, themeDisplay);
    } else {
      long plid =
          PortalUtil.getPlidFromFriendlyURL(feed.getCompanyId(), feed.getTargetLayoutFriendlyUrl());

      String portletId = PortletKeys.JOURNAL_CONTENT;

      if (Validator.isNotNull(feed.getTargetPortletId())) {
        portletId = feed.getTargetPortletId();
      }

      PortletURL entryURL =
          new PortletURLImpl(resourceRequest, portletId, plid, PortletRequest.RENDER_PHASE);

      entryURL.setParameter("struts_action", "/journal_content/view");
      entryURL.setParameter("groupId", String.valueOf(article.getGroupId()));
      entryURL.setParameter("articleId", article.getArticleId());

      return entryURL.toString();
    }
  }
  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());
  }