Message Boards

Unable to delete folder which created using DLFolderLocalServiceUtil

Rahul Bavaliya, modified 4 Years ago.

Unable to delete folder which created using DLFolderLocalServiceUtil

New Member Posts: 4 Join Date: 10/16/19 Recent Posts
LR 7.2.0) A folder created pragmatically using  "DLFolderLocalServiceUtil", using addFolder() method and it creates the folder inside the Documents and Mediasection in liferay portal. But when I try to delete that  folder from Documents and media section or move it to recycle-bin, Liferay gives error message on site which is attached here and no logs in server. Unable to find the error. If anyone know about it guide me in it. 
thumbnail
Mohammed Yasin, modified 4 Years ago.

RE: Unable to delete folder which created using DLFolderLocalServiceUtil

Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts
Hi ,
Try using this  DLAppLocalServiceUtil.addFolder(userId, repositoryId, parentFolderId, name, description, serviceContext) for creating folder
Rahul Bavaliya, modified 4 Years ago.

RE: Unable to delete folder which created using DLFolderLocalServiceUtil

New Member Posts: 4 Join Date: 10/16/19 Recent Posts
Hey, I create folder using DLAppLocalServiceUtil.addFolder(userId, repositoryId, parentFolderId, name, description, serviceContext) and folder created successfully in documents and media section but unable to delete it from portal where we show all folders and documents for site.
thumbnail
Mohammed Yasin, modified 4 Years ago.

RE: Unable to delete folder which created using DLFolderLocalServiceUtil

Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts
Hi,
Please share error log when you delete the folder from portal.
Rahul Bavaliya, modified 4 Years ago.

RE: Unable to delete folder which created using DLFolderLocalServiceUtil

New Member Posts: 4 Join Date: 10/16/19 Recent Posts
There is no error log or didn't found any error in browser console. In portal it just result message Failed to execute the request. Which I attached screenshot here.
thumbnail
Christoph Rabel, modified 4 Years ago.

RE: Unable to delete folder which created using DLFolderLocalServiceUtil

Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
1) Read the folder and manually created folders using the API and compare them. Maybe you see differences.
2) Check the permissions. Maybe there is something wrong there.
3) Set the loglevel to debug/trace for the whole com.liferay.document.library.kernel.service package.
4) Can you delete it through the API?
Rahul Bavaliya, modified 4 Years ago.

RE: Unable to delete folder which created using DLFolderLocalServiceUtil

New Member Posts: 4 Join Date: 10/16/19 Recent Posts
I created folders both ways using API and from portal.
User has permission to delete folder which one is created by API.
No logs in server or browser console.
Yes I can delete those folders using API.But not able to delete that folder from portal.
Maria Z, modified 2 Years ago.

RE: Unable to delete folder which created using DLFolderLocalServiceUtil

New Member Posts: 5 Join Date: 10/20/21 Recent Posts

Hi.

It has been a long time since you wrote the question, but today I have just fixed it. I am working with Liferay 7.3.

When you create a folder, file... in Liferay portal, an assetEntry is generated too. So, if you create a folder or a document, you need to generate this assetEntry.

In this case, after the addFolder line, you need to add another code line with this functionality:

folder = dLFolderLocalService.addFolder(userId, groupId, ...);

assetEntryLocalService.updateEntry(userId, groupId, folder.getCreateDate(), folder.getModifiedDate(), DLFolder.class.getName(), ...);

I hope it helps you for the future :)