Message Boards

Problem with custom paginated DB filter on Documents and Media

Raúl Vizuete Sánchez, modified 3 Years ago.

Problem with custom paginated DB filter on Documents and Media

New Member Post: 1 Join Date: 9/17/20 Recent Posts
I'm working on a hook of the Liferay 6.2 Documents and Media portlet. The hook is supposed to filter the folders, files and shortcuts that the portlet will show the user by a field defined in the expando bridge.

The way it's programmed at the moment, it uses "DLAppServiceUtil.getFoldersAndFileEntriesAndFileShortcuts(repositoryId, folderId, status, includeMountFolders, entryStart, entryEnd, comparator)" to receive the X amount of results desired for pagination purposes. Once those results are received, they are filtered with the field defined by the user.

The problem is, if the hook filters the results after it has received them from DB, page 1 might only contain 20 results out of the 50 results in a page even if there are more than 20 possible results to show (since it will receive 50 total results, then not show the 30 of them which get filtered out). Page 2 might show another 5 of them, page 3 15 of them, and so on.

So the question is: is it possible to receive, from a function similar to getFoldersAndFileEntriesAndFileShortcuts, the X amount of desired results from an already filtered set in DB? I need the DB request to be already looking for folders, files and shortcuts that follow those filter parameters.

Just to point out, those parameters are asociated with the folder via the expando bridge: String cons = (String) curFolder.getExpandoBridge().getAttribute("cons");