Deleting Folders

Deleting folders is similar to deleting files. There are two methods you can use to delete a folder. Click each method to see its Javadoc:

Which method you use is up to you—they both delete a folder. Follow these steps to use one of these methods to delete a folder:

  1. Get a reference to DLAppService:

    private DLAppService _dlAppService;

    For more information on this, see the section on getting a service reference in the getting started tutorial.

  2. Get the data needed to populate the arguments of the deleteFolder* method you wish to use. Since it’s common to delete a folder specified by the end user, you can extract the data you need from the request. This example does so via javax.portlet.ActionRequest and ParamUtil, but you can get the data any way you wish. Also note that this example gets only the folder ID because the next step deletes the folder with deleteFolder(folderId):

    long folderId = ParamUtil.getLong(actionRequest, "folderId");

    If you want to use the other deleteFolder method, you can also get the repository ID, parent folder ID, and folder name from the request. For more information on getting repository and folder IDs, see the getting started tutorial’s sections on specifying repositories and folders.

  3. Call the service reference’s deleteFolder* method you wish to use with the data from the previous step. This example calls deleteFolder with the folder’s ID:


You can find the full code for this example in the deleteFolders method of Liferay DXP’s EditFolderMVCActionCommand class. This class uses the Documents and Media API to implement almost all the Folder actions that the Documents and Media app supports. Also note that this deleteFolders method, as well as the rest of EditFolderMVCActionCommand, contains additional logic to suit the specific needs of the Documents and Media app.

Moving Entities to the Recycle Bin

Creating Folders

Updating Folders

Copying Folders

Moving Folders and Files

Deleting Files

« Deleting File ShortcutsMoving Entities to the Recycle Bin »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0