Example usage for com.liferay.portal.kernel.repository Repository cancelCheckOut

List of usage examples for com.liferay.portal.kernel.repository Repository cancelCheckOut

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository Repository cancelCheckOut.

Prototype

public FileVersion cancelCheckOut(long fileEntryId) throws PortalException;

Source Link

Document

Cancels the file entry check out.

Usage

From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.java

License:Open Source License

/**
 * Cancels the check out of the file entry. If a user has not checked out
 * the specified file entry, invoking this method will result in no changes.
 *
 * <p>//from  w w w .  j a  va 2s .  co  m
 * When a file entry is checked out, a PWC (private working copy) is created
 * and the original file entry is locked. A client can make as many changes
 * to the PWC as he desires without those changes being visible to other
 * users. If the user is satisfied with the changes, he may elect to check
 * in his changes, resulting in a new file version based on the PWC; the PWC
 * will be removed and the file entry will be unlocked. If the user is not
 * satisfied with the changes, he may elect to cancel his check out; this
 * results in the deletion of the PWC and unlocking of the file entry.
 * </p>
 *
 * @param  fileEntryId the primary key of the file entry to cancel the
 *         checkout
 * @throws PortalException if the file entry could not be found
 * @throws SystemException if a system exception occurred
 * @see    #checkInFileEntry(long, boolean, String, ServiceContext)
 * @see    #checkOutFileEntry(long)
 */
public void cancelCheckOut(long fileEntryId) throws PortalException, SystemException {

    Repository repository = getRepository(0, fileEntryId, 0);

    FileEntry fileEntry = repository.getFileEntry(fileEntryId);

    DLProcessorRegistryUtil.cleanUp(fileEntry.getLatestFileVersion());

    repository.cancelCheckOut(fileEntryId);

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);

    dlAppHelperLocalService.updateFileEntry(getUserId(), fileEntry, fileEntry.getFileVersion(), serviceContext);
}