在liferay中为新创建的期刊文章添加类别

时间:2014-06-10 13:14:52

标签: liferay-6

我正在尝试为新创建的文章添加类别。我的代码在这里:

ServiceContext serviceContext = ServiceContextFactory.getInstance(
    JournalArticle.class.getName(), 
    actionRequest
);
article = JournalArticleLocalServiceUtil.addArticle(
    ImporterConstants.IMPORTER_ID, 
    ImporterConstants.GROUP_ID, 
    ImporterConstants.DOC_FOLDER_ID,
    titleMap, 
    descMap, 
    content, 
    structureID, 
    templateID, 
    serviceContext
);
AssetEntry ae = AssetEntryLocalServiceUtil.fetchEntry(
    JournalArticle.class.getName(), 
    article.getResourcePrimKey()
); //returns AssetEntry
AssetEntryLocalServiceUtil.addAssetCategoryAssetEntry(48183, ae);

文章创建没有问题,但是当我尝试调用

 AssetEntryLocalServiceUtil.addAssetCategoryAssetEntry(48183, ae)

AssetCategoryLocalServiceUtil.addAssetEntryAssetCategory(ae.getEntryId(), 48183)

它不会带来任何结果,表assetentries_assetcategories没有任何变化。数字48183是表`assetcategory。

中的categoryid

你能告诉我哪里有问题吗? PS:我正在使用Liferay Portal Community Edition 6.2.0 CE GA1

由于

1 个答案:

答案 0 :(得分:0)

尝试使用所需的类别ID

更新文章资产条目
AssetEntry updateEntry(
        long userId, long groupId, String className, long classPK,
        String classUuid, long classTypeId, long[] categoryIds,
        String[] tagNames, boolean visible, Date startDate, Date endDate,
        Date publishDate, Date expirationDate, String mimeType,
        String title, String description, String summary, String url,
        String layoutUuid, int height, int width, Integer priority,
        boolean sync)
    throws PortalException, SystemException


assetEntryLocalService.updateEntry(
            userId, entry.getGroupId(), JournalArticle.class.getName(),
            entry.getEntryId(), entry.getUuid(), 0, assetCategoryIds,
            assetTagNames, visible, null, null, entry.getDisplayDate(), null,
            ContentTypes.TEXT_HTML, entry.getTitle(), null, summary, null, null,
            0, 0, null, false);