Deleting File Shortcuts

To delete a file shortcut with the Documents and Media API, you must use the deleteFileShortcut method discussed in Deleting Entities. The steps here show you how. For general information on using the API, see Documents and Media API.

Follow these steps to delete a file shortcut:

  1. Get a reference to DLAppService:

    @Reference
    private DLAppService _dlAppService;
    
  2. Get the file shortcut’s ID. Since it’s common to delete a file shortcut specified by the end user, you can extract its ID from the request. This example does so via javax.portlet.ActionRequest and ParamUtil, but you can do this any way you wish:

    long fileShortcutId = ParamUtil.getLong(actionRequest, "fileShortcutId");
    
  3. Use the service reference to call the deleteFileShortcut method with the file shortcut ID from the previous step:

    _dlAppService.deleteFileShortcut(fileShortcutId);
    

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

Moving Entities to the Recycle Bin

Creating File Shortcuts

Updating File Shortcuts

« Deleting File VersionsDeleting Folders »
Was this article helpful?
0 out of 0 found this helpful