Forums de discussion

How to get the AssetEntry for a DLFileEntry or BlogEntry?

thumbnail
Cameron McBride, modifié il y a 12 années.

How to get the AssetEntry for a DLFileEntry or BlogEntry?

Expert Publications: 269 Date d'inscription: 08/02/11 Publications récentes
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, modifié il y a 12 années.

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

Expert Publications: 269 Date d'inscription: 08/02/11 Publications récentes
Got it. Hopefully this helps someone someday...

AssetEntry asset = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), file.getPrimaryKey());
thumbnail
JL Gonzalez, modifié il y a 9 années.

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

New Member Publications: 10 Date d'inscription: 29/05/13 Publications récentes
It did, many thanks ;)
Paige L, modifié il y a 8 années.

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

Junior Member Publications: 42 Date d'inscription: 11/11/14 Publications récentes
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, modifié il y a 8 années.

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

Junior Member Publications: 42 Date d'inscription: 11/11/14 Publications récentes
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