Search in sources :

Example 11 with TrashEntry

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;
}
Also used : Song(org.liferay.jukebox.model.Song) User(com.liferay.portal.model.User) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) UnicodeProperties(com.liferay.portal.kernel.util.UnicodeProperties) ServiceContext(com.liferay.portal.service.ServiceContext) Date(java.util.Date) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 12 with TrashEntry

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;
}
Also used : Song(org.liferay.jukebox.model.Song) User(com.liferay.portal.model.User) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) ServiceContext(com.liferay.portal.service.ServiceContext) Date(java.util.Date) Indexable(com.liferay.portal.kernel.search.Indexable)

Aggregations

TrashEntry (com.liferay.portlet.trash.model.TrashEntry)12 TrashHandler (com.liferay.portal.kernel.trash.TrashHandler)6 ContainerModel (com.liferay.portal.model.ContainerModel)6 TrashedModel (com.liferay.portal.model.TrashedModel)6 Song (org.liferay.jukebox.model.Song)6 User (com.liferay.portal.model.User)5 ServiceContext (com.liferay.portal.service.ServiceContext)5 Date (java.util.Date)5 Indexable (com.liferay.portal.kernel.search.Indexable)4 Indexer (com.liferay.portal.kernel.search.Indexer)2 TrashVersion (com.liferay.portlet.trash.model.TrashVersion)2 Album (org.liferay.jukebox.model.Album)2 UnicodeProperties (com.liferay.portal.kernel.util.UnicodeProperties)1