Example usage for com.liferay.portal.kernel.repository.model FileEntry isManualCheckInRequired

List of usage examples for com.liferay.portal.kernel.repository.model FileEntry isManualCheckInRequired

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.model FileEntry isManualCheckInRequired.

Prototype

public boolean isManualCheckInRequired();

Source Link

Usage

From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java

License:Open Source License

@Override
public boolean unlockResource(WebDAVRequest webDAVRequest, String token) throws WebDAVException {

    Resource resource = getResource(webDAVRequest);

    try {/*from   w ww .  j av  a  2 s  .c o m*/
        if (resource instanceof DLFileEntryResourceImpl) {
            FileEntry fileEntry = (FileEntry) resource.getModel();

            // Do not allow WebDAV to check in a file entry if it requires a
            // manual check in

            if (fileEntry.isManualCheckInRequired()) {
                return false;
            }

            ServiceContext serviceContext = new ServiceContext();

            serviceContext.setAttribute(DL.WEBDAV_CHECK_IN_MODE, Boolean.TRUE);

            _dlAppService.checkInFileEntry(fileEntry.getFileEntryId(), token, serviceContext);

            if (webDAVRequest.isAppleDoubleRequest()) {
                _dlAppService.deleteFileEntry(fileEntry.getFileEntryId());
            }
        } else {
            Folder folder = (Folder) resource.getModel();

            _dlAppService.unlockFolder(folder.getRepositoryId(), folder.getParentFolderId(), folder.getName(),
                    token);
        }

        return true;
    } catch (InvalidLockException ile) {
        if (_log.isWarnEnabled()) {
            _log.warn(ile.getMessage());
        }
    } catch (Exception e) {
        if (_log.isWarnEnabled()) {
            _log.warn("Unable to unlock file entry", e);
        }
    }

    return false;
}