use of com.liferay.portal.kernel.repository.model.FileEntry in project liferay-ide by liferay.
the class WebServerServlet method getImage.
protected Image getImage(HttpServletRequest request, boolean getDefault) throws PortalException, SystemException {
Image image = null;
long imageId = getImageId(request);
if (imageId > 0) {
image = ImageServiceUtil.getImage(imageId);
String path = GetterUtil.getString(request.getPathInfo());
if (path.startsWith("/user_female_portrait") || path.startsWith("/user_male_portrait") || path.startsWith("/user_portrait")) {
image = getUserPortraitImageResized(image, imageId);
}
} else {
String uuid = ParamUtil.getString(request, "uuid");
long groupId = ParamUtil.getLong(request, "groupId");
boolean igSmallImage = ParamUtil.getBoolean(request, "igSmallImage");
java.lang.Object[] test;
if (Validator_IW.isNotNull(test) && (groupId > 0)) {
try {
FileEntry fileEntry = DLAppServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId);
image = convertFileEntry(igSmallImage, fileEntry);
} catch (Exception e) {
}
}
}
if (getDefault) {
if (image == null) {
if (_log.isWarnEnabled()) {
_log.warn("Get a default image for " + imageId);
}
image = getDefaultImage(request, imageId);
}
}
return image;
}
use of com.liferay.portal.kernel.repository.model.FileEntry 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.FileEntry 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;
}
use of com.liferay.portal.kernel.repository.model.FileEntry in project liferay-ide by liferay.
the class SearchResultTest method getSearchResults.
public static List<SearchResult> getSearchResults(Hits hits, Locale locale, PortletURL portletURL) {
List<SearchResult> searchResults = new ArrayList<SearchResult>();
for (Document document : hits.getDocs()) {
String entryClassName = GetterUtil.getString(document.get(Field.ENTRY_CLASS_NAME));
long entryClassPK = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));
try {
String className = entryClassName;
long classPK = entryClassPK;
FileEntry fileEntry = null;
MBMessage mbMessage = null;
if (entryClassName.equals(DLFileEntry.class.getName()) || entryClassName.equals(MBMessage.class.getName())) {
classPK = GetterUtil.getLong(document.get(Field.CLASS_PK));
long classNameId = GetterUtil.getLong(document.get(Field.CLASS_NAME_ID));
if ((classPK > 0) && (classNameId > 0)) {
className = PortalUtil.getClassName(classNameId);
if (entryClassName.equals(DLFileEntry.class.getName())) {
fileEntry = DLAppLocalServiceUtil.getFileEntry(entryClassPK);
} else if (entryClassName.equals(MBMessage.class.getName())) {
mbMessage = MBMessageLocalServiceUtil.getMessage(entryClassPK);
}
} else {
className = entryClassName;
classPK = entryClassPK;
}
}
SearchResult searchResult = new SearchResult(className, classPK);
int index = searchResults.indexOf(searchResult);
if (index < 0) {
searchResults.add(searchResult);
} else {
searchResult = searchResults.get(index);
}
if (fileEntry != null) {
Summary summary = getSummary(document, DLFileEntry.class.getName(), fileEntry.getFileEntryId(), locale, portletURL);
searchResult.addFileEntry(fileEntry, summary);
}
if (mbMessage != null) {
searchResult.addMBMessage(mbMessage);
searchResult.getMBMessages();
searchResult.getFileEntryTuples();
}
if (entryClassName.equals(JournalArticle.class.getName())) {
String version = document.get(Field.VERSION);
searchResult.addVersion(version);
}
if ((mbMessage == null) && (fileEntry == null)) {
Summary summary = getSummary(document, className, classPK, locale, portletURL);
searchResult.setSummary(summary);
} else {
if (searchResult.getSummary() == null) {
Summary summary = getSummary(className, classPK, locale, portletURL);
searchResult.setSummary(summary);
}
}
} catch (Exception e) {
if (_log.isWarnEnabled()) {
_log.warn("Search index is stale and contains entry {" + entryClassPK + "}");
}
}
}
return searchResults;
}
use of com.liferay.portal.kernel.repository.model.FileEntry in project liferay-ide by liferay.
the class LiferayMediaItemService method doGetMediaItem.
protected MediaItem doGetMediaItem(UserId userId, String appId, String albumId, String mediaItemId, Set<String> fields, SecurityToken securityToken) throws Exception {
long mediaItemIdLong = GetterUtil.getLong(mediaItemId);
FileEntry fileEntry = DLAppServiceUtil.getFileEntry(mediaItemIdLong);
return toMediaItem(fileEntry, fields, securityToken);
}
Aggregations