List of usage examples for com.liferay.portal.kernel.trash TrashHandler addDeletionSystemEvent
public SystemEvent addDeletionSystemEvent(long userId, long groupId, long classPK, String classUuid, String referrerClassName) throws PortalException;
From source file:com.liferay.trash.service.impl.TrashEntryLocalServiceImpl.java
License:Open Source License
/** * Moves an entry to trash./*from www .j a va 2 s . c o m*/ * * @param userId the primary key of the user removing the entity * @param groupId the primary key of the entry's group * @param className the class name of the entity * @param classPK the primary key of the entity * @param classUuid the UUID of the entity's class * @param referrerClassName the referrer class name used to add a deletion * {@link SystemEvent} * @param status the status of the entity prior to being moved to trash * @param statusOVPs the primary keys and statuses of any of the entry's * versions (e.g., {@link * com.liferay.portlet.documentlibrary.model.DLFileVersion}) * @param typeSettingsProperties the type settings properties * @return the trashEntry */ @Override public TrashEntry addTrashEntry(long userId, long groupId, String className, long classPK, String classUuid, String referrerClassName, int status, List<ObjectValuePair<Long, Integer>> statusOVPs, UnicodeProperties typeSettingsProperties) throws PortalException { User user = userLocalService.getUserById(userId); long classNameId = classNameLocalService.getClassNameId(className); TrashEntry trashEntry = trashEntryPersistence.fetchByC_C(classNameId, classPK); if (trashEntry != null) { return trashEntry; } TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className); SystemEvent systemEvent = trashHandler.addDeletionSystemEvent(userId, groupId, classPK, classUuid, referrerClassName); long entryId = counterLocalService.increment(); trashEntry = trashEntryPersistence.create(entryId); trashEntry.setGroupId(groupId); trashEntry.setCompanyId(user.getCompanyId()); trashEntry.setUserId(user.getUserId()); trashEntry.setUserName(user.getFullName()); trashEntry.setCreateDate(new Date()); trashEntry.setClassNameId(classNameId); trashEntry.setClassPK(classPK); if (systemEvent != null) { trashEntry.setSystemEventSetKey(systemEvent.getSystemEventSetKey()); } if (typeSettingsProperties != null) { trashEntry.setTypeSettingsProperties(typeSettingsProperties); } trashEntry.setStatus(status); trashEntryPersistence.update(trashEntry); if (statusOVPs != null) { for (ObjectValuePair<Long, Integer> statusOVP : statusOVPs) { long versionId = counterLocalService.increment(); TrashVersion trashVersion = trashVersionPersistence.create(versionId); trashVersion.setEntryId(entryId); trashVersion.setClassNameId(classNameId); trashVersion.setClassPK(statusOVP.getKey()); trashVersion.setStatus(statusOVP.getValue()); trashVersionPersistence.update(trashVersion); } } return trashEntry; }