Canceling a Check-out

The Documents and Media API also lets you cancel a check-out. Use caution with this operation—it discards any edits made since check-out. If you’re sure you want to cancel a check-out, do so with the DLAppService method cancelCheckOut:

cancelCheckOut(long fileEntryId)

For a full description of this method and its parameter, see its Javadoc. If you invoke this method without error, you can safely assume that it discarded the private working copy and unlocked the file. Other users should now be able to check out and edit the file.

Follow these steps to cancel a check-out:

  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 ID of the file whose check-out you want to cancel. Since it’s common to cancel a check-out in response to a user action, you can extract the file ID from the request. This example does so via javax.portlet.ActionRequest and ParamUtil, but you can get it any way you wish:

    long fileEntryId = ParamUtil.getLong(actionRequest, "fileEntryId");
  3. Call the service reference’s cancelCheckOut method with the file’s ID:


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

File Check-out

File Check-in

Updating Files

« File Check-inCopying and Moving Entities »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0