use of com.liferay.portal.kernel.trash.TrashHandler in project liferay-ide by liferay.
the class JukeBoxBaseTrashHandler method getTrashContainedModelTrashRenderers.
@Override
public List<TrashRenderer> getTrashContainedModelTrashRenderers(long classPK, int start, int end) throws PortalException, SystemException {
List<TrashRenderer> trashRenderers = new ArrayList<TrashRenderer>();
List<Song> songs = SongLocalServiceUtil.getSongsByAlbumId(classPK, start, end);
for (Song song : songs) {
TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(Song.class.getName());
TrashRenderer trashRenderer = trashHandler.getTrashRenderer(song.getSongId());
trashRenderers.add(trashRenderer);
}
return trashRenderers;
}
use of com.liferay.portal.kernel.trash.TrashHandler 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.portal.kernel.trash.TrashHandler 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;
}
use of com.liferay.portal.kernel.trash.TrashHandler in project liferay-ide by liferay.
the class AlbumStagedModelDataHandler method doRestoreStagedModel.
@Override
protected void doRestoreStagedModel(PortletDataContext portletDataContext, Album album) throws Exception {
long userId = portletDataContext.getUserId(album.getUserUuid());
Album existingAlbum = AlbumLocalServiceUtil.fetchAlbumByUuidAndGroupId(album.getUuid(), portletDataContext.getScopeGroupId());
if ((existingAlbum == null) || !existingAlbum.isInTrash()) {
return;
}
TrashHandler trashHandler = existingAlbum.getTrashHandler();
if (trashHandler.isRestorable(existingAlbum.getAlbumId())) {
trashHandler.restoreTrashEntry(userId, existingAlbum.getAlbumId());
}
}
use of com.liferay.portal.kernel.trash.TrashHandler in project liferay-ide by liferay.
the class ArtistStagedModelDataHandler method doRestoreStagedModel.
@Override
protected void doRestoreStagedModel(PortletDataContext portletDataContext, Artist artist) throws Exception {
long userId = portletDataContext.getUserId(artist.getUserUuid());
Artist existingArtist = ArtistLocalServiceUtil.fetchArtistByUuidAndGroupId(artist.getUuid(), portletDataContext.getScopeGroupId());
if ((existingArtist == null) || !existingArtist.isInTrash()) {
return;
}
TrashHandler trashHandler = existingArtist.getTrashHandler();
if (trashHandler.isRestorable(existingArtist.getArtistId())) {
trashHandler.restoreTrashEntry(userId, existingArtist.getArtistId());
}
}
Aggregations