留言板

How to get the AssetEntry for a DLFileEntry or BlogEntry?

thumbnail
Cameron McBride,修改在12 年前。

How to get the AssetEntry for a DLFileEntry or BlogEntry?

Expert 帖子: 269 加入日期: 11-2-8 最近的帖子
List<dlfileentry> files = DLFileEntryLocalServiceUtil.getDLFileEntries(0, DLFileEntryLocalServiceUtil.getDLFileEntriesCount());
for (DLFileEntry file : files) {
  AssetEntry asset = AssetEntryLocalServiceUtil.getAssetEntry(file.getFileEntryId());
}</dlfileentry>

That will throw an error because the the entry id of the file is not the same as what is in the asset entry.

List<assetentry> assets = AssetEntryLocalServiceUtil.getAssetEntries(0, AssetEntryLocalServiceUtil.getAssetEntriesCount());
for (AssetEntry asset : assets) {
  System.out.println("# " + asset.getEntryId() + " - " + asset.getClassName() + " - " + asset.getTitle() + " - " + asset.getViewCount());
}</assetentry>

That will print all the assets and you can see that your file is in there. How can you get the asset entry id from the file?
thumbnail
Cameron McBride,修改在12 年前。

RE: How to get the AssetEntry for a DLFileEntry or BlogEntry?

Expert 帖子: 269 加入日期: 11-2-8 最近的帖子
Got it. Hopefully this helps someone someday...

AssetEntry asset = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), file.getPrimaryKey());
thumbnail
JL Gonzalez,修改在9 年前。

RE: How to get the AssetEntry for a DLFileEntry or BlogEntry?

New Member 帖子: 10 加入日期: 13-5-29 最近的帖子
It did, many thanks ;)
Paige L,修改在8 年前。

RE: How to get the AssetEntry for a DLFileEntry or BlogEntry?

Junior Member 帖子: 42 加入日期: 14-11-11 最近的帖子
Thank you thank you thank you. Going to see if it works for me now, but even if it doesn't, I highly respect you as someone who reports back solutions even when you don't have, helping the confused from four years in the future. Thank you.
Paige L,修改在8 年前。

RE: How to get the AssetEntry for a DLFileEntry or BlogEntry?

Junior Member 帖子: 42 加入日期: 14-11-11 最近的帖子
I'm still getting the error (No AssetEntry exists with the key {classNameId=10011, classPK=975773}) but I'll respond back if I find a way to fix it