Foros de discusión

How to get the AssetEntry for a DLFileEntry or BlogEntry?

thumbnail
Cameron McBride, modificado hace 12 años.

How to get the AssetEntry for a DLFileEntry or BlogEntry?

Expert Mensajes: 269 Fecha de incorporación: 8/02/11 Mensajes recientes
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, modificado hace 12 años.

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

Expert Mensajes: 269 Fecha de incorporación: 8/02/11 Mensajes recientes
Got it. Hopefully this helps someone someday...

AssetEntry asset = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), file.getPrimaryKey());
thumbnail
JL Gonzalez, modificado hace 9 años.

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

New Member Mensajes: 10 Fecha de incorporación: 29/05/13 Mensajes recientes
It did, many thanks ;)
Paige L, modificado hace 8 años.

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

Junior Member Mensajes: 42 Fecha de incorporación: 11/11/14 Mensajes recientes
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, modificado hace 8 años.

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

Junior Member Mensajes: 42 Fecha de incorporación: 11/11/14 Mensajes recientes
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