Message Boards

Create folders and sub folders from portlet component

shiva xcontrol, modified 2 Years ago.

Create folders and sub folders from portlet component

New Member Post: 1 Join Date: 9/29/21 Recent Posts

Hello Liferay Community,

liferay-ce-portal-7.3.3-ga4

I have a requirement to read excel data and put it under web content and sort them into different folders and subfolders. How to do achieve this?

All I found is creating files and folders under Documents and Media library

Follow these steps to create a folder with the DLAppService method addFolder:

  1. Get a reference to DLAppService:

    @Reference
    private DLAppService _dlAppService;
    
  2. Get the data needed to populate the addFolder method’s arguments. Since it’s common to create a folder with data submitted by the end user, you can extract the data from the request. This example does so via javax.portlet.ActionRequest and ParamUtil:

    long repositoryId = ParamUtil.getLong(actionRequest, "repositoryId");
    long parentFolderId = ParamUtil.getLong(actionRequest, "parentFolderId");
    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");
    
    ServiceContext serviceContext = ServiceContextFactory.getInstance(
                DLFolder.class.getName(), actionRequest);
    
  1. Call the service reference’s addFolder method with the data from the previous step:

    Folder folder = _dlAppService.addFolder(
                            repositoryId, parentFolderId, name, description, 
                            serviceContext);
    

    The method returns a Folder object, which this example sets to a variable for later use. Note, however, that you don’t have to do this.

 

Please let me know or guide me on how to solve this problem.

 

Thanks in advance.

Best regards
A Liferay Beginner

Abdul Kareem, modified 2 Years ago.

RE: Create folders and sub folders from portlet component

Junior Member Posts: 30 Join Date: 9/4/14 Recent Posts

Hi Shiva,

Firstly decide whether you want to create folders under Web content or Documents and Media library.

If under web content use :

@Reference
    private JournalFolderLocalService journalFolderLocalService;

JournalFolder journalFolder = journalFolderLocalService.addFolder(themeDisplay.getUserId(), groupId, 
                            parentFolderId, folderName, "", serviceContext);

If under Documents and Media then use :

DLFolderLocalServiceUtil.addFolder(userId, groupId, 
                                    repositoryId, mountPoint, parentFolderId, name, description, hidden, serviceContext)

thumbnail
Olaf Kock, modified 2 Years ago.

RE: Create folders and sub folders from portlet component

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts

Please don't crosspost. I've deleted your other, identical post. Here's what I originally answered there:

Document Library is the place where binary data goes. Web Content is a specific type of content that has nothing to do with binary (or other) uploaded files.

I can't imagine any business requirement where the storage place is specified. I can imagine a presentation requirement, but that has nothing to do with the storage location of documents.

In other words: You didn't find anything because there's no way. You also wouldn't try to buy groceries in the electronics store just because somebody told you so. This is comparable.

If you let us know about the underlying business problem that you're trying to solve, we might generate ideas how to design/implement. Just make sure they're business language, not implementation details.