use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.
the class SongLocalServiceImpl method moveSongFromTrash.
@Override
public Song moveSongFromTrash(long userId, long songId, long albumId) throws PortalException, SystemException {
Song song = getSong(songId);
TrashEntry trashEntry = song.getTrashEntry();
if (trashEntry.isTrashEntry(Song.class, songId)) {
restoreSongFromTrash(userId, songId);
} else {
// Entry
TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntry.getEntryId(), Song.class.getName(), songId);
int status = WorkflowConstants.STATUS_APPROVED;
if (trashVersion != null) {
status = trashVersion.getStatus();
}
ServiceContext serviceContext = new ServiceContext();
// Entry
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
song.setModifiedDate(serviceContext.getModifiedDate(now));
song.setStatus(status);
song.setStatusByUserId(user.getUserId());
song.setStatusByUserName(user.getFullName());
song.setStatusDate(serviceContext.getModifiedDate(now));
songPersistence.update(song);
// Asset
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
// Indexer
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
indexer.reindex(song);
if (trashVersion != null) {
trashVersionLocalService.deleteTrashVersion(trashVersion);
}
}
return songLocalService.moveSong(songId, albumId);
}
use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.
the class ArtistClp method getTrashEntry.
@Override
public TrashEntry getTrashEntry() throws PortalException, SystemException {
if (!isInTrash()) {
return null;
}
TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(), getTrashEntryClassPK());
if (trashEntry != null) {
return trashEntry;
}
TrashHandler trashHandler = getTrashHandler();
if (!Validator.isNull(trashHandler.getContainerModelClassName())) {
ContainerModel containerModel = trashHandler.getParentContainerModel(this);
while (containerModel != null) {
if (containerModel instanceof TrashedModel) {
TrashedModel trashedModel = (TrashedModel) containerModel;
return trashedModel.getTrashEntry();
}
trashHandler = TrashHandlerRegistryUtil.getTrashHandler(trashHandler.getContainerModelClassName());
if (trashHandler == null) {
return null;
}
containerModel = trashHandler.getContainerModel(containerModel.getParentContainerModelId());
}
}
return null;
}
use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.
the class AlbumLocalServiceImpl method moveAlbumToTrash.
@Indexable(type = IndexableType.REINDEX)
@Override
public Album moveAlbumToTrash(long userId, long albumId) throws PortalException, SystemException {
ServiceContext serviceContext = new ServiceContext();
// Folder
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
Album album = albumPersistence.findByPrimaryKey(albumId);
int oldStatus = album.getStatus();
album.setModifiedDate(serviceContext.getModifiedDate(now));
album.setStatus(WorkflowConstants.STATUS_IN_TRASH);
album.setStatusByUserId(user.getUserId());
album.setStatusByUserName(user.getFullName());
album.setStatusDate(serviceContext.getModifiedDate(now));
albumPersistence.update(album);
// Asset
assetEntryLocalService.updateVisible(Album.class.getName(), album.getAlbumId(), false);
// Trash
TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, album.getGroupId(), Album.class.getName(), album.getAlbumId(), album.getUuid(), null, oldStatus, null, null);
// Folders and entries
List<Song> songs = songLocalService.getSongsByAlbumId(album.getAlbumId());
moveDependentsToTrash(songs, trashEntry.getEntryId());
return album;
}
use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.
the class AlbumLocalServiceImpl method restoreAlbumFromTrash.
@Indexable(type = IndexableType.REINDEX)
@Override
public Album restoreAlbumFromTrash(long userId, long albumId) throws PortalException, SystemException {
ServiceContext serviceContext = new ServiceContext();
// Folder
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
Album album = albumPersistence.findByPrimaryKey(albumId);
TrashEntry trashEntry = trashEntryLocalService.getEntry(Album.class.getName(), albumId);
album.setModifiedDate(serviceContext.getModifiedDate(now));
album.setStatus(trashEntry.getStatus());
album.setStatusByUserId(user.getUserId());
album.setStatusByUserName(user.getFullName());
album.setStatusDate(serviceContext.getModifiedDate(now));
albumPersistence.update(album);
assetEntryLocalService.updateVisible(Album.class.getName(), album.getAlbumId(), true);
// Songs
List<Song> songs = songLocalService.getSongsByAlbumId(album.getGroupId(), album.getAlbumId(), WorkflowConstants.STATUS_IN_TRASH);
restoreDependentsFromTrash(songs, trashEntry.getEntryId());
// Trash
trashEntryLocalService.deleteEntry(trashEntry.getEntryId());
return album;
}
use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.
the class SongModelImpl method getTrashEntry.
@Override
public TrashEntry getTrashEntry() throws PortalException, SystemException {
if (!isInTrash()) {
return null;
}
TrashEntry trashEntry = TrashEntryLocalServiceUtil.fetchEntry(getModelClassName(), getTrashEntryClassPK());
if (trashEntry != null) {
return trashEntry;
}
TrashHandler trashHandler = getTrashHandler();
if (!Validator.isNull(trashHandler.getContainerModelClassName())) {
ContainerModel containerModel = trashHandler.getParentContainerModel(this);
while (containerModel != null) {
if (containerModel instanceof TrashedModel) {
TrashedModel trashedModel = (TrashedModel) containerModel;
return trashedModel.getTrashEntry();
}
trashHandler = TrashHandlerRegistryUtil.getTrashHandler(trashHandler.getContainerModelClassName());
if (trashHandler == null) {
return null;
}
containerModel = trashHandler.getContainerModel(containerModel.getParentContainerModelId());
}
}
return null;
}
Aggregations