Deleting File Shortcuts

The Documents and Media API also lets you delete file shortcuts. To do so, use the DLAppService method deleteFileShortcut with the ID of the shortcut you want to delete:

deleteFileShortcut(long fileShortcutId)

Follow these steps to use this method to delete a file shortcut:

  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 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:


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 »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0