Search in sources :

Example 6 with TrashEntry

use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.

the class AlbumModelImpl 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;
}
Also used : TrashEntry(com.liferay.portlet.trash.model.TrashEntry) TrashHandler(com.liferay.portal.kernel.trash.TrashHandler) TrashedModel(com.liferay.portal.model.TrashedModel) ContainerModel(com.liferay.portal.model.ContainerModel)

Example 7 with TrashEntry

use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.

the class ArtistModelImpl 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;
}
Also used : TrashEntry(com.liferay.portlet.trash.model.TrashEntry) TrashHandler(com.liferay.portal.kernel.trash.TrashHandler) TrashedModel(com.liferay.portal.model.TrashedModel) ContainerModel(com.liferay.portal.model.ContainerModel)

Example 8 with TrashEntry

use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.

the class SongClp 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;
}
Also used : TrashEntry(com.liferay.portlet.trash.model.TrashEntry) TrashHandler(com.liferay.portal.kernel.trash.TrashHandler) TrashedModel(com.liferay.portal.model.TrashedModel) ContainerModel(com.liferay.portal.model.ContainerModel)

Example 9 with TrashEntry

use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.

the class AlbumClp 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;
}
Also used : TrashEntry(com.liferay.portlet.trash.model.TrashEntry) TrashHandler(com.liferay.portal.kernel.trash.TrashHandler) TrashedModel(com.liferay.portal.model.TrashedModel) ContainerModel(com.liferay.portal.model.ContainerModel)

Example 10 with TrashEntry

use of com.liferay.portlet.trash.model.TrashEntry in project liferay-ide by liferay.

the class AlbumLocalServiceImpl method restoreDependentsFromTrash.

protected void restoreDependentsFromTrash(List<Song> songs, long trashEntryId) throws PortalException, SystemException {
    for (Song song : songs) {
        // Song
        TrashEntry trashEntry = trashEntryLocalService.fetchEntry(Song.class.getName(), song.getSongId());
        if (trashEntry != null) {
            continue;
        }
        TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntryId, Song.class.getName(), song.getSongId());
        int oldStatus = WorkflowConstants.STATUS_APPROVED;
        if (trashVersion != null) {
            oldStatus = trashVersion.getStatus();
        }
        song.setStatus(oldStatus);
        songPersistence.update(song);
        if (trashVersion != null) {
            trashVersionLocalService.deleteTrashVersion(trashVersion);
        }
        if (oldStatus == WorkflowConstants.STATUS_APPROVED) {
            assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), true);
        }
        // Indexer
        Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
        indexer.reindex(song);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) Indexer(com.liferay.portal.kernel.search.Indexer) TrashVersion(com.liferay.portlet.trash.model.TrashVersion)

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