use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.
the class SongLocalServiceImpl method moveSongToTrash.
@Indexable(type = IndexableType.REINDEX)
public Song moveSongToTrash(long userId, Song song) throws PortalException, SystemException {
ServiceContext serviceContext = new ServiceContext();
// Entry
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
int oldStatus = song.getStatus();
song.setModifiedDate(serviceContext.getModifiedDate(now));
song.setStatus(WorkflowConstants.STATUS_IN_TRASH);
song.setStatusByUserId(user.getUserId());
song.setStatusByUserName(user.getFullName());
song.setStatusDate(serviceContext.getModifiedDate(now));
// Asset
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
// Trash
UnicodeProperties typeSettingsProperties = new UnicodeProperties();
typeSettingsProperties.put("title", song.getName());
TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, song.getGroupId(), Song.class.getName(), song.getSongId(), song.getUuid(), null, oldStatus, null, typeSettingsProperties);
song.setName(TrashUtil.getTrashTitle(trashEntry.getEntryId()));
songPersistence.update(song);
return song;
}
use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.
the class SongLocalServiceImpl method restoreSongFromTrash.
@Indexable(type = IndexableType.REINDEX)
@Override
public Song restoreSongFromTrash(long userId, long songId) throws PortalException, SystemException {
ServiceContext serviceContext = new ServiceContext();
// Entry
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
TrashEntry trashEntry = trashEntryLocalService.getEntry(Song.class.getName(), songId);
Song song = songPersistence.findByPrimaryKey(songId);
song.setName(TrashUtil.getOriginalTitle(song.getName()));
song.setModifiedDate(serviceContext.getModifiedDate(now));
song.setStatus(trashEntry.getStatus());
song.setStatusByUserId(user.getUserId());
song.setStatusByUserName(user.getFullName());
song.setStatusDate(serviceContext.getModifiedDate(now));
songPersistence.update(song);
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), true);
trashEntryLocalService.deleteEntry(Song.class.getName(), songId);
return song;
}
Aggregations