001
014
015 package com.liferay.portlet.trash.service.impl;
016
017 import com.liferay.portal.kernel.exception.SystemException;
018 import com.liferay.portal.kernel.util.Validator;
019 import com.liferay.portal.util.PortalUtil;
020 import com.liferay.portlet.trash.model.TrashVersion;
021 import com.liferay.portlet.trash.service.base.TrashVersionLocalServiceBaseImpl;
022
023 import java.util.List;
024
025
028 public class TrashVersionLocalServiceImpl
029 extends TrashVersionLocalServiceBaseImpl {
030
031 @Override
032 public void addTrashVersion(
033 long trashEntryId, String className, long classPK, int status)
034 throws SystemException {
035
036 long versionId = counterLocalService.increment();
037
038 TrashVersion trashVersion = trashVersionPersistence.create(versionId);
039
040 trashVersion.setEntryId(trashEntryId);
041 trashVersion.setClassName(className);
042 trashVersion.setClassPK(classPK);
043 trashVersion.setStatus(status);
044
045 trashVersionPersistence.update(trashVersion);
046 }
047
048 @Override
049 public TrashVersion fetchVersion(
050 long entryId, String className, long classPK)
051 throws SystemException {
052
053 long classNameId = PortalUtil.getClassNameId(className);
054
055 TrashVersion version = trashVersionPersistence.fetchByE_C_C(
056 entryId, classNameId, classPK);
057
058 return version;
059 }
060
061 @Override
062 public List<TrashVersion> getVersions(long entryId) throws SystemException {
063 return trashVersionPersistence.findByEntryId(entryId);
064 }
065
066 @Override
067 public List<TrashVersion> getVersions(long entryId, String className)
068 throws SystemException {
069
070 if (Validator.isNull(className)) {
071 return trashVersionPersistence.findByEntryId(entryId);
072 }
073
074 long classNameId = PortalUtil.getClassNameId(className);
075
076 return trashVersionPersistence.findByE_C(entryId, classNameId);
077 }
078
079
087 @Override
088 public List<TrashVersion> getVersions(String className, long classPK)
089 throws SystemException {
090
091 long classNameId = PortalUtil.getClassNameId(className);
092
093 return trashVersionPersistence.findByC_C(classNameId, classPK);
094 }
095
096 }