Search code examples
javajakarta-eecontent-management-systemliferayliferay-6

How use the getFolders() method of the DLFolderLocalServiceUtil class?


I am absolutly new in LifeRay development and I have some doubts related to the use of the DLFolderLocalServiceUtil class.

In my code I have something like this:

List<DLFolder> listFolder = DLFolderLocalServiceUtil.getDLFolders(-1, -1);
private Map<String, DLFolder> treePath = new TreeMap<String, DLFolder>();

What exaclty do the previous code? I think that is is something related to the LifeRay document library. I think that the previous code retrieve the root of the document library of my portal.

But, if my reasoning is correct, what exactly is the document library in LifeRay? Is it something used to stored documents on the portal? If so what exactly is a document in LifeRay? any type of file or specific type of content?

Looking on the official LifeRAy documentation, here: https://docs.liferay.com/portal/6.2/javadocs-all/com/liferay/portlet/documentlibrary/service/DLFolderLocalServiceUtil.html

it seems to me that, in the previous code snippet, it is used this version of the getDLFolders() method:

getDLFolders(int start, int end)

and say that:

Returns a range of all the document library folders

But what exactly mean a range of all document library folder? And what means if, as in the previous snippet, is used the start and end values setted to -1 ?


Solution

  • Yes, this service is related to the Documents and Media portlet which can be found within Content of a site's Admin area. The source code package structure designates this portlet as the document_library portlet (dated but applicable wiki page). The portlet serves as the management facility for all document based content for any type of document.

    The portlet uses both the database and file system in providing document management functionality. If you navigate to the same directory level as your ${LIFERAY_HOME} and have a look, you'll see a data folder. Within this folder you'll notice a document_library folder. The directory structure going forward corresponds to companyId / folder (internally managed association) for a specific file / individual versions of a specific file.

    One of the available actions for the portlet is to add a folder. Any folders added this way are managed through the database. These folders are the ones returned by the service method, for the entirety of the portal, along with some folders Liferay uses. The folders specific to each file will not show up when using this service.

    Liferay uses -1 to designate "all". Sometimes you see the usage as getDLFolders(QueryUtil.ALL_POS, QueryUtil.ALL_POS) where ALL_POS is short for "all possible" and it simply wraps a constant value.