Posted on 1 Comment

Determining Absolute Path for FileEntry in Liferay

Liferay Logo

In case you are wondering how to determine the absolute path to FileEntry objects in Liferay (i.e. Document and Media Library elements) here is how it works.

First, add the following to your


Then, to calculate the absolute path for a FileEntry use the following code:

private String getDLFileAbsPath(FileEntry fileEntry) 
throws PortalException, SystemException {
  return PropsUtils.get("dl.hook.file.system.root.dir") + "/" 
    + fileEntry.getCompanyId() + "/"
    + fileEntry.getFolderId() + "/"
    + ((DLFileEntry) fileEntry.getModel()).getName() + "/"
    + fileEntry.getVersion();

Note that in order to get the foldername where your FileEntry resides you need to cast FileEntry to DLFileEntry, as shown above.