/** * Deletes the trash entry with the entity class name and class primary key. * * <p>This method throws a {@link TrashPermissionException} with type {@link * TrashPermissionException#DELETE} if the user did not have permission to delete the trash entry. * * @param className the class name of the entity * @param classPK the primary key of the entity * @throws PortalException if a trash entry with the entity class name and primary key could not * be found or if the user did not have permission to delete the entry */ @Override public void deleteEntry(String className, long classPK) throws PortalException { TrashEntry entry = trashEntryLocalService.fetchEntry(className, classPK); if (entry == null) { entry = new TrashEntryImpl(); entry.setClassName(className); entry.setClassPK(classPK); } deleteEntry(entry); }
@Override public List<TrashEntry> getEntries(Hits hits) { List<TrashEntry> entries = new ArrayList<TrashEntry>(); for (Document document : hits.getDocs()) { String entryClassName = GetterUtil.getString(document.get(Field.ENTRY_CLASS_NAME)); long classPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); try { TrashEntry entry = TrashEntryLocalServiceUtil.fetchEntry(entryClassName, classPK); if (entry == null) { String userName = GetterUtil.getString(document.get(Field.REMOVED_BY_USER_NAME)); Date removedDate = document.getDate(Field.REMOVED_DATE); entry = new TrashEntryImpl(); entry.setClassName(entryClassName); entry.setClassPK(classPK); entry.setUserName(userName); entry.setCreateDate(removedDate); String rootEntryClassName = GetterUtil.getString(document.get(Field.ROOT_ENTRY_CLASS_NAME)); long rootEntryClassPK = GetterUtil.getLong(document.get(Field.ROOT_ENTRY_CLASS_PK)); TrashEntry rootTrashEntry = TrashEntryLocalServiceUtil.fetchEntry(rootEntryClassName, rootEntryClassPK); if (rootTrashEntry != null) { entry.setRootEntry(rootTrashEntry); } } entries.add(entry); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn( "Unable to find trash entry for " + entryClassName + " with primary key " + classPK); } } } return entries; }