Search in sources :

Example 41 with Album

use of org.liferay.jukebox.model.Album 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)

Example 42 with Album

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

the class AlbumLocalServiceImpl method restoreAlbumFromTrash.

@Indexable(type = IndexableType.REINDEX)
@Override
public Album restoreAlbumFromTrash(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);
    TrashEntry trashEntry = trashEntryLocalService.getEntry(Album.class.getName(), albumId);
    album.setModifiedDate(serviceContext.getModifiedDate(now));
    album.setStatus(trashEntry.getStatus());
    album.setStatusByUserId(user.getUserId());
    album.setStatusByUserName(user.getFullName());
    album.setStatusDate(serviceContext.getModifiedDate(now));
    albumPersistence.update(album);
    assetEntryLocalService.updateVisible(Album.class.getName(), album.getAlbumId(), true);
    // Songs
    List<Song> songs = songLocalService.getSongsByAlbumId(album.getGroupId(), album.getAlbumId(), WorkflowConstants.STATUS_IN_TRASH);
    restoreDependentsFromTrash(songs, trashEntry.getEntryId());
    // Trash
    trashEntryLocalService.deleteEntry(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)

Example 43 with Album

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

the class AlbumLocalServiceImpl method updateAsset.

public void updateAsset(long userId, Album album, long[] assetCategoryIds, String[] assetTagNames, long[] assetLinkEntryIds) throws PortalException, SystemException {
    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, album.getGroupId(), album.getCreateDate(), album.getModifiedDate(), Album.class.getName(), album.getAlbumId(), album.getUuid(), 0, assetCategoryIds, assetTagNames, true, null, null, null, ContentTypes.TEXT_HTML, album.getName(), null, null, null, null, 0, 0, null, false);
    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED);
}
Also used : AssetEntry(com.liferay.portlet.asset.model.AssetEntry) Album(org.liferay.jukebox.model.Album)

Example 44 with Album

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

the class AlbumLocalServiceImpl method addAlbum.

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

Example 45 with Album

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

the class JukeboxPortlet method deleteAlbum.

public void deleteAlbum(ActionRequest request, ActionResponse response) throws Exception {
    long albumId = ParamUtil.getLong(request, "albumId");
    boolean moveToTrash = ParamUtil.getBoolean(request, "moveToTrash");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Album.class.getName(), request);
    try {
        if (moveToTrash) {
            Album album = AlbumServiceUtil.moveAlbumToTrash(albumId);
            Map<String, String[]> data = new HashMap<String, String[]>();
            data.put("deleteEntryClassName", new String[] { Album.class.getName() });
            data.put("deleteEntryTitle", new String[] { album.getName() });
            data.put("restoreEntryIds", new String[] { String.valueOf(albumId) });
            SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_DELETE_SUCCESS_DATA, data);
            SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE);
        } else {
            AlbumServiceUtil.deleteAlbum(albumId, serviceContext);
            SessionMessages.add(request, "albumDeleted");
        }
        sendRedirect(request, response);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());
        response.setRenderParameter("jspPage", "/html/error.jsp");
    }
}
Also used : HashMap(java.util.HashMap) ServiceContext(com.liferay.portal.service.ServiceContext) Album(org.liferay.jukebox.model.Album) SongNameException(org.liferay.jukebox.SongNameException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) DuplicatedSongException(org.liferay.jukebox.DuplicatedSongException) AlbumNameException(org.liferay.jukebox.AlbumNameException) ArtistNameException(org.liferay.jukebox.ArtistNameException)

Aggregations

Album (org.liferay.jukebox.model.Album)97 NoSuchAlbumException (org.liferay.jukebox.NoSuchAlbumException)55 StringBundler (com.liferay.portal.kernel.util.StringBundler)53 SystemException (com.liferay.portal.kernel.exception.SystemException)37 Session (com.liferay.portal.kernel.dao.orm.Session)34 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)32 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)31 Query (com.liferay.portal.kernel.dao.orm.Query)22 AlbumImpl (org.liferay.jukebox.model.impl.AlbumImpl)18 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)17 ArrayList (java.util.ArrayList)17 List (java.util.List)17 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)11 Indexable (com.liferay.portal.kernel.search.Indexable)8 User (com.liferay.portal.model.User)6 Song (org.liferay.jukebox.model.Song)6 ServiceContext (com.liferay.portal.service.ServiceContext)4 Date (java.util.Date)4 Artist (org.liferay.jukebox.model.Artist)4 PortalException (com.liferay.portal.kernel.exception.PortalException)3