Search in sources :

Example 1 with Indexable

use of com.liferay.portal.kernel.search.Indexable in project liferay-ide by liferay.

the class ArtistLocalServiceImpl method updateArtist.

@Indexable(type = IndexableType.REINDEX)
public Artist updateArtist(long userId, long artistId, String name, String bio, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException {
    // Event
    User user = userPersistence.findByPrimaryKey(userId);
    validate(name);
    Artist artist = artistPersistence.findByPrimaryKey(artistId);
    artist.setModifiedDate(serviceContext.getModifiedDate(null));
    artist.setName(name);
    artist.setBio(bio);
    artist.setExpandoBridgeAttributes(serviceContext);
    artistPersistence.update(artist);
    if (inputStream != null) {
        Repository repository = PortletFileRepositoryUtil.fetchPortletRepository(serviceContext.getScopeGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);
        if (repository != null) {
            try {
                PortletFileRepositoryUtil.deletePortletFileEntry(repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(artist.getArtistId()));
            } catch (Exception e) {
                if (_log.isDebugEnabled()) {
                    _log.debug("Cannot delete artist image");
                }
            }
        }
        PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Artist.class.getName(), artist.getArtistId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(artist.getArtistId()), StringPool.BLANK, true);
    }
    // Asset
    updateAsset(userId, artist, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
    return artist;
}
Also used : Artist(org.liferay.jukebox.model.Artist) Repository(com.liferay.portal.model.Repository) User(com.liferay.portal.model.User) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) ArtistNameException(org.liferay.jukebox.ArtistNameException) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 2 with Indexable

use of com.liferay.portal.kernel.search.Indexable in project liferay-ide by liferay.

the class ArtistLocalServiceImpl method addArtist.

@Indexable(type = IndexableType.REINDEX)
public Artist addArtist(long userId, String name, String bio, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException {
    long groupId = serviceContext.getScopeGroupId();
    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();
    validate(name);
    long artistId = counterLocalService.increment();
    Artist artist = artistPersistence.create(artistId);
    artist.setUuid(serviceContext.getUuid());
    artist.setGroupId(groupId);
    artist.setCompanyId(user.getCompanyId());
    artist.setUserId(user.getUserId());
    artist.setUserName(user.getFullName());
    artist.setCreateDate(serviceContext.getCreateDate(now));
    artist.setModifiedDate(serviceContext.getModifiedDate(now));
    artist.setName(name);
    artist.setBio(bio);
    artist.setExpandoBridgeAttributes(serviceContext);
    artistPersistence.update(artist);
    if (inputStream != null) {
        PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Artist.class.getName(), artist.getArtistId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(artist.getArtistId()), StringPool.BLANK, true);
    }
    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {
        addEntryResources(artist, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions());
    } else {
        addEntryResources(artist, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
    }
    // Message boards
    mbMessageLocalService.addDiscussionMessage(userId, artist.getUserName(), groupId, Artist.class.getName(), artistId, WorkflowConstants.ACTION_PUBLISH);
    // Asset
    updateAsset(userId, artist, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
    return artist;
}
Also used : Artist(org.liferay.jukebox.model.Artist) User(com.liferay.portal.model.User) Date(java.util.Date) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 3 with Indexable

use of com.liferay.portal.kernel.search.Indexable in project liferay-ide by liferay.

the class ArtistLocalServiceImpl method deleteArtist.

@Indexable(type = IndexableType.DELETE)
public Artist deleteArtist(long artistId) throws PortalException, SystemException {
    Artist artist = artistPersistence.findByPrimaryKey(artistId);
    List<Album> albums = albumLocalService.getAlbumsByArtistId(artistId);
    for (Album album : albums) {
        albumLocalService.deleteAlbum(album.getAlbumId());
    }
    try {
        PortletFileRepositoryUtil.deletePortletFileEntry(artist.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(artistId));
    } catch (Exception e) {
    }
    return artistPersistence.remove(artistId);
}
Also used : Artist(org.liferay.jukebox.model.Artist) Album(org.liferay.jukebox.model.Album) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) ArtistNameException(org.liferay.jukebox.ArtistNameException) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 4 with Indexable

use of com.liferay.portal.kernel.search.Indexable in project liferay-ide by liferay.

the class SongLocalServiceImpl method moveSong.

@Indexable(type = IndexableType.REINDEX)
@Override
public Song moveSong(long songId, long albumId) throws PortalException, SystemException {
    Song song = getSong(songId);
    song.setAlbumId(albumId);
    songPersistence.update(song);
    return song;
}
Also used : Song(org.liferay.jukebox.model.Song) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 5 with Indexable

use of com.liferay.portal.kernel.search.Indexable 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;
}
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) Album(org.liferay.jukebox.model.Album) Date(java.util.Date) Indexable(com.liferay.portal.kernel.search.Indexable)

Aggregations

Indexable (com.liferay.portal.kernel.search.Indexable)14 User (com.liferay.portal.model.User)10 Song (org.liferay.jukebox.model.Song)9 Album (org.liferay.jukebox.model.Album)8 Date (java.util.Date)7 PortalException (com.liferay.portal.kernel.exception.PortalException)5 SystemException (com.liferay.portal.kernel.exception.SystemException)5 Repository (com.liferay.portal.model.Repository)5 ServiceContext (com.liferay.portal.service.ServiceContext)4 TrashEntry (com.liferay.portlet.trash.model.TrashEntry)4 Folder (com.liferay.portal.kernel.repository.model.Folder)3 Artist (org.liferay.jukebox.model.Artist)3 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)2 AlbumNameException (org.liferay.jukebox.AlbumNameException)2 ArtistNameException (org.liferay.jukebox.ArtistNameException)2 UnicodeProperties (com.liferay.portal.kernel.util.UnicodeProperties)1 DuplicatedSongException (org.liferay.jukebox.DuplicatedSongException)1 SongNameException (org.liferay.jukebox.SongNameException)1