Fórum

How to get the AssetEntry for a DLFileEntry or BlogEntry?

thumbnail
Cameron McBride, modificado 12 Anos atrás.

How to get the AssetEntry for a DLFileEntry or BlogEntry?

Expert Postagens: 269 Data de Entrada: 08/02/11 Postagens Recentes
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 12 Anos atrás.

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

Expert Postagens: 269 Data de Entrada: 08/02/11 Postagens Recentes
Got it. Hopefully this helps someone someday...

AssetEntry asset = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), file.getPrimaryKey());
thumbnail
JL Gonzalez, modificado 9 Anos atrás.

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

New Member Postagens: 10 Data de Entrada: 29/05/13 Postagens Recentes
It did, many thanks ;)
Paige L, modificado 8 Anos atrás.

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

Junior Member Postagens: 42 Data de Entrada: 11/11/14 Postagens Recentes
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 8 Anos atrás.

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

Junior Member Postagens: 42 Data de Entrada: 11/11/14 Postagens Recentes
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