use of com.liferay.portal.service.ServiceContext in project liferay-ide by liferay.
the class AdminPortlet method updateKBTemplate.
public void updateKBTemplate(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
String portletId = PortalUtil.getPortletId(actionRequest);
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
long kbTemplateId = ParamUtil.getLong(actionRequest, "kbTemplateId");
String title = ParamUtil.getString(actionRequest, "title");
String content = ParamUtil.getString(actionRequest, "content");
ServiceContext serviceContext = ServiceContextFactory.getInstance(KBTemplate.class.getName(), actionRequest);
if (cmd.equals(Constants.ADD)) {
KBTemplateServiceUtil.addKBTemplate(portletId, title, content, serviceContext);
} else if (cmd.equals(Constants.UPDATE)) {
KBTemplateServiceUtil.updateKBTemplate(kbTemplateId, title, content, serviceContext);
}
}
use of com.liferay.portal.service.ServiceContext 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.service.ServiceContext in project liferay-ide by liferay.
the class EditRecordAction method updateRecord.
protected DDLRecord updateRecord(ActionRequest actionRequest) throws Exception {
UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest);
ServiceContext serviceContext = ServiceContextFactory.getInstance(DDLRecord.class.getName(), uploadPortletRequest);
long recordId = ParamUtil.getLong(serviceContext, "recordId");
long recordSetId = ParamUtil.getLong(serviceContext, "recordSetId");
return DDLUtil.updateRecord(recordId, recordSetId, true, serviceContext);
}
use of com.liferay.portal.service.ServiceContext in project liferay-ide by liferay.
the class EditRecordAction method revertRecordVersion.
protected void revertRecordVersion(ActionRequest actionRequest) throws Exception {
long recordId = ParamUtil.getLong(actionRequest, "recordId");
String version = ParamUtil.getString(actionRequest, "version");
ServiceContext serviceContext = ServiceContextFactory.getInstance(DDLRecord.class.getName(), actionRequest);
DDLRecordServiceUtil.revertRecordVersion(recordId, version, serviceContext);
}
use of com.liferay.portal.service.ServiceContext in project liferay-ide by liferay.
the class LiferayAlbumService method doUpdateAlbum.
protected void doUpdateAlbum(UserId userId, String appId, Album album, String albumId, SecurityToken securityToken) throws Exception {
long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));
User user = UserLocalServiceUtil.getUserById(userIdLong);
if (!ShindigUtil.isValidUser(user)) {
return;
}
Group group = user.getGroup();
long groupIdLong = group.getGroupId();
ServiceContext serviceContext = new ServiceContext();
serviceContext.setAddGroupPermissions(true);
serviceContext.setAddGuestPermissions(true);
serviceContext.setExpandoBridgeAttributes(SerializerUtil.toExpandoAttributes(album, _ALBUM_FIELDS, user.getCompanyId(), DLFolder.class.getName()));
serviceContext.setScopeGroupId(groupIdLong);
if (albumId == null) {
DLAppServiceUtil.addFolder(groupIdLong, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, album.getTitle(), album.getDescription(), serviceContext);
} else {
Folder folder = DLAppLocalServiceUtil.getFolder(GetterUtil.getLong(albumId));
DLAppServiceUtil.updateFolder(folder.getFolderId(), album.getTitle(), album.getDescription(), serviceContext);
}
}
Aggregations