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