001
014
015 package com.liferay.portlet.documentlibrary.util;
016
017 import com.liferay.portal.kernel.lock.BaseLockListener;
018 import com.liferay.portal.kernel.log.Log;
019 import com.liferay.portal.kernel.log.LogFactoryUtil;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.service.ServiceContext;
022 import com.liferay.portal.util.PropsValues;
023 import com.liferay.portlet.documentlibrary.model.DLFileEntryConstants;
024 import com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil;
025
026
029 public class DLFileEntryLockListener extends BaseLockListener {
030
031 public String getClassName() {
032 return DLFileEntryConstants.getClassName();
033 }
034
035 @Override
036 public void onAfterExpire(String key) {
037 long fileEntryId = GetterUtil.getLong(key);
038
039 try {
040 if (PropsValues.DL_FILE_ENTRY_LOCK_POLICY == 1) {
041 DLFileEntryServiceUtil.checkInFileEntry(
042 fileEntryId, true, "Automatic timeout checkin",
043 new ServiceContext());
044
045 if (_log.isDebugEnabled()) {
046 _log.debug("Lock expired and checked in " + fileEntryId);
047 }
048 }
049 else {
050 DLFileEntryServiceUtil.cancelCheckOut(fileEntryId);
051
052 if (_log.isDebugEnabled()) {
053 _log.debug(
054 "Lock expired and canceled check out of " +
055 fileEntryId);
056 }
057 }
058 }
059 catch (Exception e) {
060 _log.error(e, e);
061 }
062 }
063
064 private static Log _log = LogFactoryUtil.getLog(
065 DLFileEntryLockListener.class);
066
067 }