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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations