Example usage for com.liferay.portal.webdav LockException LockException

List of usage examples for com.liferay.portal.webdav LockException LockException

Introduction

In this page you can find the example usage for com.liferay.portal.webdav LockException LockException.

Prototype

public LockException(Throwable cause) 

Source Link

Usage

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

License:Open Source License

protected boolean deleteResource(long groupId, long parentFolderId, String name, String lockUuid)
        throws Exception {

    try {//  www.  j  a va2 s .c  om
        Folder folder = _dlAppService.getFolder(groupId, parentFolderId, name);

        _dlAppService.deleteFolder(folder.getFolderId());

        return true;
    } catch (NoSuchFolderException nsfe) {
        if (_log.isDebugEnabled()) {
            _log.debug(nsfe, nsfe);
        }

        try {
            FileEntry fileEntry = _dlAppService.getFileEntry(groupId, parentFolderId, name);

            if (!hasLock(fileEntry, lockUuid) && (fileEntry.getLock() != null)) {

                StringBundler sb = new StringBundler(4);

                sb.append("Inconsistent file lock state for file entry ");
                sb.append(fileEntry.getPrimaryKey());
                sb.append(" and lock UUID ");
                sb.append(lockUuid);

                throw new LockException(sb.toString());
            }

            _dlAppService.deleteFileEntryByTitle(groupId, parentFolderId, name);

            return true;
        } catch (NoSuchFileEntryException nsfee) {
            if (_log.isDebugEnabled()) {
                _log.debug(nsfee, nsfee);
            }
        }
    }

    return false;
}