Search in sources :

Example 31 with Artist

use of org.liferay.jukebox.model.Artist 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 32 with Artist

use of org.liferay.jukebox.model.Artist 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 33 with Artist

use of org.liferay.jukebox.model.Artist 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 34 with Artist

use of org.liferay.jukebox.model.Artist in project liferay-ide by liferay.

the class ArtistPermission method contains.

public static boolean contains(PermissionChecker permissionChecker, long artistId, String actionId) throws PortalException, SystemException {
    Artist artist = ArtistLocalServiceUtil.getArtist(artistId);
    Boolean hasPermission = StagingPermissionUtil.hasPermission(permissionChecker, artist.getGroupId(), Artist.class.getName(), artist.getArtistId(), AlbumsPortlet.PORTLET_ID, actionId);
    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }
    return permissionChecker.hasPermission(artist.getGroupId(), Artist.class.getName(), artist.getArtistId(), actionId);
}
Also used : Artist(org.liferay.jukebox.model.Artist)

Example 35 with Artist

use of org.liferay.jukebox.model.Artist in project liferay-ide by liferay.

the class ArtistIndexer method reindexEntries.

protected void reindexEntries(long companyId) throws PortalException, SystemException {
    final Collection<Document> documents = new ArrayList<Document>();
    ActionableDynamicQuery actionableDynamicQuery = new ArtistActionableDynamicQuery() {

        @Override
        protected void addCriteria(DynamicQuery dynamicQuery) {
        }

        @Override
        protected void performAction(Object object) throws PortalException {
            Artist artist = (Artist) object;
            Document document = getDocument(artist);
            documents.add(document);
        }
    };
    actionableDynamicQuery.setCompanyId(companyId);
    actionableDynamicQuery.performActions();
    SearchEngineUtil.updateDocuments(getSearchEngineId(), companyId, documents);
}
Also used : Artist(org.liferay.jukebox.model.Artist) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) ArtistActionableDynamicQuery(org.liferay.jukebox.service.persistence.ArtistActionableDynamicQuery) ArrayList(java.util.ArrayList) ArtistActionableDynamicQuery(org.liferay.jukebox.service.persistence.ArtistActionableDynamicQuery) Document(com.liferay.portal.kernel.search.Document) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) ArtistActionableDynamicQuery(org.liferay.jukebox.service.persistence.ArtistActionableDynamicQuery)

Aggregations

Artist (org.liferay.jukebox.model.Artist)79 NoSuchArtistException (org.liferay.jukebox.NoSuchArtistException)45 StringBundler (com.liferay.portal.kernel.util.StringBundler)43 SystemException (com.liferay.portal.kernel.exception.SystemException)30 Session (com.liferay.portal.kernel.dao.orm.Session)28 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)26 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)25 Query (com.liferay.portal.kernel.dao.orm.Query)18 ArrayList (java.util.ArrayList)15 ArtistImpl (org.liferay.jukebox.model.impl.ArtistImpl)15 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)14 List (java.util.List)14 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)9 Document (com.liferay.portal.kernel.search.Document)5 DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)4 Album (org.liferay.jukebox.model.Album)4 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)3 Indexable (com.liferay.portal.kernel.search.Indexable)3 Element (com.liferay.portal.kernel.xml.Element)3 PortalException (com.liferay.portal.kernel.exception.PortalException)2