use of com.liferay.portal.model.User 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 com.liferay.portal.model.User 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 com.liferay.portal.model.User in project liferay-ide by liferay.
the class SongLocalServiceImpl method moveSongFromTrash.
@Override
public Song moveSongFromTrash(long userId, long songId, long albumId) throws PortalException, SystemException {
Song song = getSong(songId);
TrashEntry trashEntry = song.getTrashEntry();
if (trashEntry.isTrashEntry(Song.class, songId)) {
restoreSongFromTrash(userId, songId);
} else {
// Entry
TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntry.getEntryId(), Song.class.getName(), songId);
int status = WorkflowConstants.STATUS_APPROVED;
if (trashVersion != null) {
status = trashVersion.getStatus();
}
ServiceContext serviceContext = new ServiceContext();
// Entry
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
song.setModifiedDate(serviceContext.getModifiedDate(now));
song.setStatus(status);
song.setStatusByUserId(user.getUserId());
song.setStatusByUserName(user.getFullName());
song.setStatusDate(serviceContext.getModifiedDate(now));
songPersistence.update(song);
// Asset
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
// Indexer
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
indexer.reindex(song);
if (trashVersion != null) {
trashVersionLocalService.deleteTrashVersion(trashVersion);
}
}
return songLocalService.moveSong(songId, albumId);
}
use of com.liferay.portal.model.User in project liferay-ide by liferay.
the class UserLocalServiceImpl method updateOpenId.
/**
* Updates the user's OpenID.
*
* @param userId the primary key of the user
* @param openId the new OpenID
* @return the user
* @throws PortalException if a user with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public User updateOpenId(long userId, String openId) throws PortalException, SystemException {
openId = openId.trim();
User user = userPersistence.findByPrimaryKey(userId);
user.setOpenId(openId);
userPersistence.update(user);
return user;
}
use of com.liferay.portal.model.User in project liferay-ide by liferay.
the class UserLocalServiceImpl method updateCreateDate.
/**
* Updates the user's creation date.
*
* @param userId the primary key of the user
* @param createDate the new creation date
* @return the user
* @throws PortalException if a user with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public User updateCreateDate(long userId, Date createDate) throws PortalException, SystemException {
User user = userPersistence.findByPrimaryKey(userId);
user.setCreateDate(createDate);
userPersistence.update(user);
return user;
}
Aggregations