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.UnicodeProperties;
019 import com.liferay.portal.kernel.util.Validator;
020 import com.liferay.portal.util.PortalUtil;
021 import com.liferay.portlet.trash.model.TrashVersion;
022 import com.liferay.portlet.trash.service.base.TrashVersionLocalServiceBaseImpl;
023
024 import java.util.List;
025
026
029 public class TrashVersionLocalServiceImpl
030 extends TrashVersionLocalServiceBaseImpl {
031
032 @Override
033 public void addTrashVersion(
034 long trashEntryId, String className, long classPK, int status,
035 UnicodeProperties typeSettingsProperties)
036 throws SystemException {
037
038 long versionId = counterLocalService.increment();
039
040 TrashVersion trashVersion = trashVersionPersistence.create(versionId);
041
042 trashVersion.setEntryId(trashEntryId);
043 trashVersion.setClassName(className);
044 trashVersion.setClassPK(classPK);
045
046 if (typeSettingsProperties != null) {
047 trashVersion.setTypeSettingsProperties(typeSettingsProperties);
048 }
049
050 trashVersion.setStatus(status);
051
052 trashVersionPersistence.update(trashVersion);
053 }
054
055 @Override
056 public TrashVersion deleteTrashVersion(
057 long entryId, String className, long classPK)
058 throws SystemException {
059
060 TrashVersion trashVersion = fetchVersion(entryId, className, classPK);
061
062 if (trashVersion != null) {
063 return deleteTrashVersion(trashVersion);
064 }
065
066 return null;
067 }
068
069 @Override
070 public TrashVersion fetchVersion(
071 long entryId, String className, long classPK)
072 throws SystemException {
073
074 long classNameId = PortalUtil.getClassNameId(className);
075
076 return trashVersionPersistence.fetchByE_C_C(
077 entryId, classNameId, classPK);
078 }
079
080 @Override
081 public List<TrashVersion> getVersions(long entryId) throws SystemException {
082 return trashVersionPersistence.findByEntryId(entryId);
083 }
084
085 @Override
086 public List<TrashVersion> getVersions(long entryId, String className)
087 throws SystemException {
088
089 if (Validator.isNull(className)) {
090 return trashVersionPersistence.findByEntryId(entryId);
091 }
092
093 long classNameId = PortalUtil.getClassNameId(className);
094
095 return trashVersionPersistence.findByE_C(entryId, classNameId);
096 }
097
098
106 @Override
107 public List<TrashVersion> getVersions(String className, long classPK)
108 throws SystemException {
109
110 long classNameId = PortalUtil.getClassNameId(className);
111
112 return trashVersionPersistence.findByC_C(classNameId, classPK);
113 }
114
115 }