Liferay Asset - 如何在不更改创建日期的情况下更新liferay资产?

时间:2015-03-18 10:29:00

标签: java liferay

我使用com.liferay.portlet.asset.service.AssetEntryLocalServiceUtil来更新现有条目或创建新条目(如果它不存在)。但是我不想更改createdDate,所以我不想传递这两个参数。此覆盖函数存在,但不推荐使用。我应该使用哪种功能? Java文档不包含任何注释。

实施例: 此函数接受createdDate和updatedDate参数:

        AssetEntryLocalServiceUtil.updateEntry(userId, // userId
                groupId,// groupId
                new Date(),// create date
                new Date(),// modifiedDate
                PeriodicalIssueDto.class.getName(),// class name
                dto.getId(), // class PK
                "" + dto.getId(), // class uuid
                0L, // classTypeId
                null,// categoryIds
                null,// tagNames
                true,// visible
                new Date(),// startDate
                null,// endDate
                null, // expirationDate
                "text",// mimeType
                dto.getTitle(),// title
                null,// description
                null,// summary
                null, // url
                null,// layoutUuid
                0, // height
                0,// width
                0, // priority
                false// sync
                );

但是不推荐使用createDate和modifiedDate的类似函数:

        AssetEntryLocalServiceUtil.updateEntry(
                userId, // userId
                groupId,// groupId
                PeriodicalIssueDto.class.getName(),// class name
                dto.getId(), // class PK
                "" + dto.getId(), // class uuid
                0L, // classTypeId
                null,// categoryIds
                null,// tagNames
                true,// visible
                new Date(),// startDate
                null,// endDate
                null, // expirationDate
                "text",// mimeType
                dto.getTitle(),// title
                null,// description
                null,// summary
                null, // url
                null,// layoutUuid
                0, // height
                0,// width
                0, // priority
                false// sync
                );

如何在不处理createDate和modifiedDate myslef的情况下创建或更新新条目?

1 个答案:

答案 0 :(得分:0)

经过一点点反编译后,我找到了答案。

应使用带有createDate和modifiedDate的版本。

createDate仅适用于新条目。如果传递null,则自动创建新的Date()

modifiedDate根据输入参数设置。如果传递null,则自动使用新的Date()。