예제 #1
0
  protected void verifyPermissionsAndAssets(JournalArticle article) throws PortalException {

    long groupId = article.getGroupId();
    String articleId = article.getArticleId();
    double version = article.getVersion();

    if (article.getResourcePrimKey() <= 0) {
      article =
          JournalArticleLocalServiceUtil.checkArticleResourcePrimKey(groupId, articleId, version);
    }

    ResourceLocalServiceUtil.addResources(
        article.getCompanyId(),
        0,
        0,
        JournalArticle.class.getName(),
        article.getResourcePrimKey(),
        false,
        false,
        false);

    AssetEntry assetEntry =
        AssetEntryLocalServiceUtil.fetchEntry(
            JournalArticle.class.getName(), article.getResourcePrimKey());

    if (assetEntry == null) {
      try {
        JournalArticleLocalServiceUtil.updateAsset(article.getUserId(), article, null, null, null);
      } catch (Exception e) {
        if (_log.isWarnEnabled()) {
          _log.warn(
              "Unable to update asset for article " + article.getId() + ": " + e.getMessage());
        }
      }
    } else if ((article.getStatus() == WorkflowConstants.STATUS_DRAFT)
        && (article.getVersion() == JournalArticleConstants.VERSION_DEFAULT)) {

      AssetEntryLocalServiceUtil.updateEntry(
          assetEntry.getClassName(), assetEntry.getClassPK(), null, assetEntry.isVisible());
    }

    try {
      JournalArticleLocalServiceUtil.checkStructure(groupId, articleId, version);
    } catch (NoSuchStructureException nsse) {
      if (_log.isWarnEnabled()) {
        _log.warn("Removing reference to missing structure for article " + article.getId());
      }

      article.setStructureId(StringPool.BLANK);
      article.setTemplateId(StringPool.BLANK);

      JournalArticleLocalServiceUtil.updateJournalArticle(article);
    } catch (Exception e) {
      _log.error("Unable to check the structure for article " + article.getId(), e);
    }
  }
  public void updateAsset(
      long userId, TasksEntry tasksEntry, long[] assetCategoryIds, String[] assetTagNames)
      throws PortalException, SystemException {

    AssetEntryLocalServiceUtil.updateEntry(
        userId,
        tasksEntry.getGroupId(),
        TasksEntry.class.getName(),
        tasksEntry.getTasksEntryId(),
        assetCategoryIds,
        assetTagNames);
  }
  public void updateAsset(
      MicroblogsEntry microblogsEntry, long[] assetCategoryIds, String[] assetTagNames)
      throws PortalException, SystemException {

    Group group = GroupLocalServiceUtil.getCompanyGroup(microblogsEntry.getCompanyId());

    AssetEntryLocalServiceUtil.updateEntry(
        microblogsEntry.getUserId(),
        group.getGroupId(),
        MicroblogsEntry.class.getName(),
        microblogsEntry.getMicroblogsEntryId(),
        assetCategoryIds,
        assetTagNames);
  }