Search in sources :

Example 6 with ServiceContext

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);
    }
}
Also used : ServiceContext(com.liferay.portal.service.ServiceContext) KBTemplate(com.liferay.knowledgebase.model.KBTemplate)

Example 7 with 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);
}
Also used : Song(org.liferay.jukebox.model.Song) TrashEntry(com.liferay.portlet.trash.model.TrashEntry) User(com.liferay.portal.model.User) Indexer(com.liferay.portal.kernel.search.Indexer) ServiceContext(com.liferay.portal.service.ServiceContext) TrashVersion(com.liferay.portlet.trash.model.TrashVersion) Date(java.util.Date)

Example 8 with ServiceContext

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);
}
Also used : ServiceContext(com.liferay.portal.service.ServiceContext) UploadPortletRequest(com.liferay.portal.kernel.upload.UploadPortletRequest) DDLRecord(com.liferay.portlet.dynamicdatalists.model.DDLRecord)

Example 9 with 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);
}
Also used : ServiceContext(com.liferay.portal.service.ServiceContext) DDLRecord(com.liferay.portlet.dynamicdatalists.model.DDLRecord)

Example 10 with 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);
    }
}
Also used : Group(com.liferay.portal.model.Group) User(com.liferay.portal.model.User) ServiceContext(com.liferay.portal.service.ServiceContext) Folder(com.liferay.portal.kernel.repository.model.Folder) DLFolder(com.liferay.portlet.documentlibrary.model.DLFolder)

Aggregations

ServiceContext (com.liferay.portal.service.ServiceContext)57 User (com.liferay.portal.model.User)11 PrincipalException (com.liferay.portal.security.auth.PrincipalException)11 InputStream (java.io.InputStream)11 AlbumNameException (org.liferay.jukebox.AlbumNameException)9 ArtistNameException (org.liferay.jukebox.ArtistNameException)9 DuplicatedSongException (org.liferay.jukebox.DuplicatedSongException)9 SongNameException (org.liferay.jukebox.SongNameException)9 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)8 Song (org.liferay.jukebox.model.Song)8 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)7 Date (java.util.Date)7 SystemException (com.liferay.portal.kernel.exception.SystemException)6 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)6 PortalException (com.liferay.portal.kernel.exception.PortalException)5 JSONObject (com.liferay.portal.kernel.json.JSONObject)5 Artist (org.liferay.jukebox.model.Artist)5 Gadget (com.liferay.opensocial.model.Gadget)4 Folder (com.liferay.portal.kernel.repository.model.Folder)4 Element (com.liferay.portal.kernel.xml.Element)4