Getting Multiple Entity Types

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:

  1. Get a reference to DLAppService:

    @Reference
    private DLAppService _dlAppService;
    
  2. 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) via ParamUtil:

    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.

  3. 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 the DLFolderConstants constant DEFAULT_PARENT_FOLDER_ID to specify the repository’s root folder.
    • WorkflowConstants.STATUS_APPROVED: Uses the WorkflowConstants constant STATUS_APPROVED to specify only files/folders that have been approved via workflow.
    • QueryUtil.ALL_POS: Uses the QueryUtil constant ALL_POS for the start and end positions in the results. This specifies all results, bypassing pagination.

Getting Files

Getting Folders

« Getting FoldersAdaptive Media »
这篇文章有帮助吗?
0 人中有 0 人觉得有帮助