Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Tim Cardwell
Find All DLFolder and DLFileEntry items
February 18, 2013 8:40 AM

Tim Cardwell

Rank: Junior Member

Posts: 30

Join Date: July 19, 2012

Recent Posts

I'm creating a JSON Web Service that returns all of the DLFolder and DLFileEntry items a user has access to. Currently, I'm figuring out all of the groups that the user belongs to, and then using a liferay API call to retrieve all of the DLFolder and DLFileEntry items that group has access to. I do this for each group the user is in. My current code looks like this:

 2// Get Groups that the current user is in
 3long[] allGroupIds = currentUser.getGroupIds();
 5// Get Files and Folders based on group ids
 6List<DLFolder> allFolders = new ArrayList<DLFolder>();
 7List<DLFileEntry> allFileEntries = new ArrayList<DLFileEntry>();
 8for(int i = 0; i < allGroupIds.length; i++)
10    allFolders.addAll(DLFolderUtil.filterFindByGroupId(allGroupIds[i]));
11    allFileEntries.addAll(DLFileEntryUtil.filterFindByGroupId(allGroupIds[i]));

What I want is something like this:

2// Get all Files and Folders
3List<DLFolder> allFolders = DLFolderUtil.filterFindAll();
4List<DLFileEntry> allFileEntries = DLFileEntryUtil.filterFindAll();

I have looked through the liferay API and can't seem to find a way to retrieve all the DLFolder and DLFileEntry items without looping through the groups. (Note: There are liferay API calls that return all of the files and folders on the entire site, but I only want the ones that a user has access too.)

Is there a way to do this?

Neil Francese
RE: Find All DLFolder and DLFileEntry items
May 7, 2014 5:50 AM

Neil Francese

Rank: New Member

Posts: 19

Join Date: April 3, 2012

Recent Posts

Did you find a way to do this?

Krzysztof Gołębiowski
RE: Find All DLFolder and DLFileEntry items
May 7, 2014 1:50 PM

Krzysztof Gołębiowski

Rank: Liferay Master

Posts: 514

Join Date: June 25, 2011

Recent Posts

Hello Tim and Neil,
I don't know if I understood the question clearly. You just want to list all files/folders the user is permitted to view?
If yes, then it should be done automatically when using methods from DLFileEntryService and DLFolderService. All not-Local services check permissions by default.

If you really have to use DLFolderUtil method (which I think, in this case, calls persistence object), you can always iterate over objects array and verify if logged user has access with with permission checker.