use of com.liferay.portal.kernel.repository.model.Folder in project com-liferay-apio-architect by liferay.
the class MediaObjectNestedCollectionResource method _addFileEntry.
private FileEntry _addFileEntry(Long folderId, MediaObjectCreatorForm mediaObjectCreatorForm) throws PortalException {
Folder folder = _dlAppService.getFolder(folderId);
BinaryFile binaryFile = mediaObjectCreatorForm.getBinaryFile();
return _dlAppService.addFileEntry(folder.getGroupId(), folderId, mediaObjectCreatorForm.getName(), binaryFile.getMimeType(), mediaObjectCreatorForm.getTitle(), mediaObjectCreatorForm.getDescription(), null, binaryFile.getInputStream(), binaryFile.getSize(), new ServiceContext());
}
use of com.liferay.portal.kernel.repository.model.Folder in project com-liferay-apio-architect by liferay.
the class MediaObjectNestedCollectionResource method _getPageItems.
private PageItems<FileEntry> _getPageItems(Pagination pagination, Long folderId) throws PortalException {
Folder folder = _dlAppService.getFolder(folderId);
List<FileEntry> dlFileEntries = _dlAppService.getFileEntries(folder.getGroupId(), folder.getFolderId(), pagination.getStartPosition(), pagination.getEndPosition());
int count = _dlAppService.getFileEntriesCount(folder.getGroupId(), folder.getFolderId());
return new PageItems<>(dlFileEntries, count);
}
use of com.liferay.portal.kernel.repository.model.Folder in project com-liferay-apio-architect by liferay.
the class FolderNestedCollectionResource method _addFolder.
private Folder _addFolder(Long groupId, FolderForm folderForm) throws PortalException {
long parentFolderId = 0;
Try<Folder> folderTry = Try.fromFallible(() -> _dlAppService.getFolder(groupId, parentFolderId, folderForm.getName()));
if (folderTry.isSuccess()) {
throw new BadRequestException("A folder with that name already exists");
}
return _dlAppService.addFolder(groupId, parentFolderId, folderForm.getName(), folderForm.getDescription(), new ServiceContext());
}
use of com.liferay.portal.kernel.repository.model.Folder in project liferay-ide by liferay.
the class SongLocalServiceImpl method addSong.
@Indexable(type = IndexableType.REINDEX)
public Song addSong(long userId, long albumId, String name, String songFileName, InputStream songInputStream, String lyricsFileName, InputStream lyricsInputStream, ServiceContext serviceContext) throws PortalException, SystemException {
long groupId = serviceContext.getScopeGroupId();
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
long songId = counterLocalService.increment();
Album album = albumPersistence.findByPrimaryKey(albumId);
validate(songId, groupId, album.getArtistId(), albumId, name);
Song song = songPersistence.create(songId);
song.setUuid(serviceContext.getUuid());
song.setGroupId(groupId);
song.setCompanyId(user.getCompanyId());
song.setUserId(user.getUserId());
song.setUserName(user.getFullName());
song.setCreateDate(serviceContext.getCreateDate(now));
song.setModifiedDate(serviceContext.getModifiedDate(now));
song.setArtistId(album.getArtistId());
song.setAlbumId(albumId);
song.setName(name);
song.setExpandoBridgeAttributes(serviceContext);
songPersistence.update(song);
if ((songInputStream != null) || (lyricsInputStream != null)) {
Repository repository = PortletFileRepositoryUtil.addPortletRepository(groupId, Constants.JUKEBOX_PORTLET_REPOSITORY, serviceContext);
Folder folder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(song.getSongId()), serviceContext);
if (songInputStream != null) {
Folder songFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.SONGS_FOLDER_NAME, serviceContext);
FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, songFolder.getFolderId(), songInputStream, songFileName, StringPool.BLANK, true);
DLProcessorRegistryUtil.trigger(fileEntry, null, true);
}
if (lyricsInputStream != null) {
Folder lyricsFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.LYRICS_FOLDER_NAME, serviceContext);
FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, lyricsFolder.getFolderId(), lyricsInputStream, lyricsFileName, StringPool.BLANK, true);
DLProcessorRegistryUtil.trigger(fileEntry, null, true);
}
}
if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {
addEntryResources(song, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions());
} else {
addEntryResources(song, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions());
}
// Message boards
mbMessageLocalService.addDiscussionMessage(userId, album.getUserName(), groupId, Song.class.getName(), songId, WorkflowConstants.ACTION_PUBLISH);
// Asset
updateAsset(userId, song, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
return song;
}
use of com.liferay.portal.kernel.repository.model.Folder in project liferay-ide by liferay.
the class SongLocalServiceImpl method updateSong.
@Indexable(type = IndexableType.REINDEX)
public Song updateSong(long userId, long songId, long albumId, String name, String songFileName, InputStream songInputStream, String lyricsFileName, InputStream lyricsInputStream, ServiceContext serviceContext) throws PortalException, SystemException {
// Event
User user = userPersistence.findByPrimaryKey(userId);
Song song = songPersistence.findByPrimaryKey(songId);
Album album = albumPersistence.findByPrimaryKey(albumId);
validate(songId, song.getGroupId(), album.getArtistId(), albumId, name);
song.setModifiedDate(serviceContext.getModifiedDate(null));
song.setArtistId(album.getArtistId());
song.setAlbumId(albumId);
song.setName(name);
song.setExpandoBridgeAttributes(serviceContext);
songPersistence.update(song);
if ((songInputStream != null) || (lyricsInputStream != null)) {
Repository repository = PortletFileRepositoryUtil.addPortletRepository(serviceContext.getScopeGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY, serviceContext);
Folder folder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(song.getSongId()), serviceContext);
if (songInputStream != null) {
Folder songFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.SONGS_FOLDER_NAME, serviceContext);
List<FileEntry> fileEntries = PortletFileRepositoryUtil.getPortletFileEntries(serviceContext.getScopeGroupId(), songFolder.getFolderId());
for (FileEntry fileEntry : fileEntries) {
PortletFileRepositoryUtil.deletePortletFileEntry(fileEntry.getFileEntryId());
DLProcessorRegistryUtil.cleanUp(fileEntry);
}
FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, songFolder.getFolderId(), songInputStream, songFileName, StringPool.BLANK, true);
triggerDLProcessors(fileEntry);
}
if (lyricsInputStream != null) {
Folder lyricsFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.LYRICS_FOLDER_NAME, serviceContext);
List<FileEntry> fileEntries = PortletFileRepositoryUtil.getPortletFileEntries(serviceContext.getScopeGroupId(), lyricsFolder.getFolderId());
for (FileEntry fileEntry : fileEntries) {
PortletFileRepositoryUtil.deletePortletFileEntry(fileEntry.getFileEntryId());
DLProcessorRegistryUtil.cleanUp(fileEntry);
}
FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, lyricsFolder.getFolderId(), lyricsInputStream, lyricsFileName, StringPool.BLANK, true);
triggerDLProcessors(fileEntry);
}
}
// Asset
updateAsset(userId, song, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
return song;
}
Aggregations