There are several methods in
DLAppService
that get lists containing multiple entity types. This is discussed in more
detail in
Getting Entities.
The steps here show you how to use the
getFileEntriesAndFileShortcuts
method, but you can apply them to other such methods as well.
For general information on using the Documents and Media API, see
Documents and Media API.
Note that the example in these steps gets all the files and shortcuts in the default Site repository’s root folder:
-
Get a reference to
DLAppService
:@Reference private DLAppService _dlAppService;
-
Get the data needed to populate the method’s arguments any way you wish. To specify the default Site repository, you can use the group ID as the repository ID. This example gets the group ID from the request (
javax.portlet.ActionRequest
) viaParamUtil
:long groupId = ParamUtil.getLong(actionRequest, "groupId");
Getting the parent folder ID, workflow status, and start and end parameters isn’t necessary because Liferay DXP provides constants for them. The next step shows this in detail.
-
Call the service reference method with the data from the previous step and any other values you want to provide. This example calls
getFileEntriesAndFileShortcuts
with the group ID from the previous step and constants for the remaining arguments:_dlAppService.getFileEntriesAndFileShortcuts( groupId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS )
Here’s a description of the arguments used in this example:
groupId
: Using the group ID as the repository ID specifies that the operation takes place in the default site repository.DLFolderConstants.DEFAULT_PARENT_FOLDER_ID
: Uses theDLFolderConstants
constantDEFAULT_PARENT_FOLDER_ID
to specify the repository’s root folder.WorkflowConstants.STATUS_APPROVED
: Uses theWorkflowConstants
constantSTATUS_APPROVED
to specify only files/folders that have been approved via workflow.QueryUtil.ALL_POS
: Uses theQueryUtil
constantALL_POS
for the start and end positions in the results. This specifies all results, bypassing pagination.