Example usage for com.liferay.portal.kernel.theme ThemeDisplay getUserId

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getUserId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getUserId.

Prototype

public long getUserId() 

Source Link

Document

Returns the ID of the user for which the current request is being handled.

Usage

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

/**
 * @deprecated As of 3.0.0, replaced by {@link #publishPortlet(long, long,
 *             long, long, long, String, Map)}
 *//*  ww w.j  a  v  a 2 s . c o m*/
@Deprecated
@Override
public long copyPortlet(PortletRequest portletRequest, long sourceGroupId, long targetGroupId, long sourcePlid,
        long targetPlid, String portletId) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Map<String, String[]> parameterMap = ExportImportConfigurationParameterMapFactory
            .buildParameterMap(portletRequest);

    return publishPortlet(themeDisplay.getUserId(), sourceGroupId, targetGroupId, sourcePlid, targetPlid,
            portletId, parameterMap);
}

From source file:com.liferay.exportimport.staging.StagingImpl.java

License:Open Source License

@Override
public long publishToLive(PortletRequest portletRequest, Portlet portlet) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long scopeGroupId = _portal.getScopeGroupId(_portal.getHttpServletRequest(portletRequest),
            portlet.getPortletId());/*www.  j  av a2s .  com*/

    long plid = ParamUtil.getLong(portletRequest, "plid");

    Map<String, String[]> parameterMap = ExportImportConfigurationParameterMapFactory
            .buildParameterMap(portletRequest);

    return publishPortlet(themeDisplay.getUserId(), scopeGroupId, plid, portlet.getPortletId(), parameterMap,
            false);
}

From source file:com.liferay.exportimport.web.internal.portlet.action.EditPublishConfigurationMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    hideDefaultSuccessMessage(actionRequest);

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    try {//from  ww w. j a va2 s  .  c  o m
        long exportImportConfigurationId = ParamUtil.getLong(actionRequest, "exportImportConfigurationId");

        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            setLayoutIdMap(actionRequest);

            updatePublishConfiguration(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteExportImportConfiguration(actionRequest, false);
        } else if (cmd.equals(Constants.MOVE_TO_TRASH)) {
            deleteExportImportConfiguration(actionRequest, true);
        } else if (cmd.equals(Constants.PUBLISH_TO_LIVE)) {
            setBackgroundTaskName(actionRequest, exportImportConfigurationId);

            setRedirect(actionRequest, actionResponse,
                    StagingUtil.publishLayouts(themeDisplay.getUserId(), exportImportConfigurationId));
        } else if (cmd.equals(Constants.PUBLISH_TO_REMOTE)) {
            setBackgroundTaskName(actionRequest, exportImportConfigurationId);

            setRedirect(actionRequest, actionResponse,
                    StagingUtil.copyRemoteLayouts(exportImportConfigurationId));
        } else if (cmd.equals(Constants.RELAUNCH)) {
            relaunchPublishLayoutConfiguration(themeDisplay.getUserId(), actionRequest);
        } else if (Validator.isNull(cmd)) {
            addSessionMessages(actionRequest);
        }

        sendRedirect(actionRequest, actionResponse);
    } catch (Exception e) {
        _log.error(e, e);

        SessionErrors.add(actionRequest, e.getClass(), e);
    }
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ExportImportMVCActionCommand.java

License:Open Source License

protected void exportData(ActionRequest actionRequest, Portlet portlet) throws Exception {

    try {//www  . jav  a 2 s.  c  o m
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

        long plid = ParamUtil.getLong(actionRequest, "plid");
        long groupId = ParamUtil.getLong(actionRequest, "groupId");
        String fileName = ParamUtil.getString(actionRequest, "exportFileName");

        Map<String, Serializable> exportPortletSettingsMap = ExportImportConfigurationSettingsMapFactory
                .buildExportPortletSettingsMap(themeDisplay.getUserId(), plid, groupId, portlet.getPortletId(),
                        actionRequest.getParameterMap(), themeDisplay.getLocale(), themeDisplay.getTimeZone(),
                        fileName);

        ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService
                .addDraftExportImportConfiguration(themeDisplay.getUserId(),
                        ExportImportConfigurationConstants.TYPE_EXPORT_PORTLET, exportPortletSettingsMap);

        _exportImportService.exportPortletInfoAsFileInBackground(exportImportConfiguration);
    } catch (Exception e) {
        if (e instanceof LARFileNameException) {
            throw e;
        }

        if (_log.isDebugEnabled()) {
            _log.debug(e, e);
        }

        SessionErrors.add(actionRequest, e.getClass(), e);
    }
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ExportImportMVCActionCommand.java

License:Open Source License

protected void importData(ActionRequest actionRequest, InputStream inputStream) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long plid = ParamUtil.getLong(actionRequest, "plid");
    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    Map<String, Serializable> importPortletSettingsMap = ExportImportConfigurationSettingsMapFactory
            .buildImportPortletSettingsMap(themeDisplay.getUserId(), plid, groupId, portlet.getPortletId(),
                    actionRequest.getParameterMap(), themeDisplay.getLocale(), themeDisplay.getTimeZone());

    ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService
            .addDraftExportImportConfiguration(themeDisplay.getUserId(),
                    ExportImportConfigurationConstants.TYPE_IMPORT_PORTLET, importPortletSettingsMap);

    _exportImportService.importPortletInfoInBackground(exportImportConfiguration, inputStream);
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ExportImportMVCActionCommand.java

License:Open Source License

protected void importData(ActionRequest actionRequest, String folderName) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    FileEntry fileEntry = _exportImportHelper.getTempFileEntry(groupId, themeDisplay.getUserId(), folderName);

    try (InputStream inputStream = _dlFileEntryLocalService.getFileAsStream(fileEntry.getFileEntryId(),
            fileEntry.getVersion(), false)) {

        importData(actionRequest, inputStream);

        _importLayoutsMVCActionCommand.deleteTempFileEntry(groupId, folderName);
    }/*from  www .j  ava  2s  . c  o m*/
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ExportImportMVCActionCommand.java

License:Open Source License

protected void validateFile(ActionRequest actionRequest, ActionResponse actionResponse, String folderName)
        throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    FileEntry fileEntry = _exportImportHelper.getTempFileEntry(groupId, themeDisplay.getUserId(), folderName);

    try (InputStream inputStream = _dlFileEntryLocalService.getFileAsStream(fileEntry.getFileEntryId(),
            fileEntry.getVersion(), false)) {

        MissingReferences missingReferences = validateFile(actionRequest, inputStream);

        Map<String, MissingReference> weakMissingReferences = missingReferences.getWeakMissingReferences();

        if (weakMissingReferences.isEmpty()) {
            return;
        }/* w  w  w .j a  v  a 2  s  . com*/

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

        if ((weakMissingReferences != null) && !weakMissingReferences.isEmpty()) {

            jsonObject.put("warningMessages",
                    _staging.getWarningMessagesJSONArray(themeDisplay.getLocale(), weakMissingReferences));
        }

        JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject);
    }
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ExportImportMVCActionCommand.java

License:Open Source License

protected MissingReferences validateFile(ActionRequest actionRequest, InputStream inputStream)
        throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long plid = ParamUtil.getLong(actionRequest, "plid");
    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

    Map<String, Serializable> importPortletSettingsMap = ExportImportConfigurationSettingsMapFactory
            .buildImportPortletSettingsMap(themeDisplay.getUserId(), plid, groupId, portlet.getPortletId(),
                    actionRequest.getParameterMap(), themeDisplay.getLocale(), themeDisplay.getTimeZone());

    ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService
            .addDraftExportImportConfiguration(themeDisplay.getUserId(),
                    ExportImportConfigurationConstants.TYPE_IMPORT_PORTLET, importPortletSettingsMap);

    return _exportImportService.validateImportPortletInfo(exportImportConfiguration, inputStream);
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ExportLayoutsMVCActionCommand.java

License:Open Source License

protected ExportImportConfiguration getExportImportConfiguration(ActionRequest actionRequest) throws Exception {

    Map<String, Serializable> exportLayoutSettingsMap = null;

    long exportImportConfigurationId = ParamUtil.getLong(actionRequest, "exportImportConfigurationId");

    if (exportImportConfigurationId > 0) {
        ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService
                .fetchExportImportConfiguration(exportImportConfigurationId);

        if (exportImportConfiguration != null) {
            exportLayoutSettingsMap = exportImportConfiguration.getSettingsMap();
        }//  w  w w.j av  a  2 s. c  om
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");

    if (exportLayoutSettingsMap == null) {
        long groupId = ParamUtil.getLong(actionRequest, "liveGroupId");
        long[] layoutIds = getLayoutIds(actionRequest);

        exportLayoutSettingsMap = ExportImportConfigurationSettingsMapFactory.buildExportLayoutSettingsMap(
                themeDisplay.getUserId(), groupId, privateLayout, layoutIds, actionRequest.getParameterMap(),
                themeDisplay.getLocale(), themeDisplay.getTimeZone());
    }

    String taskName = ParamUtil.getString(actionRequest, "name");

    if (Validator.isNull(taskName)) {
        if (privateLayout) {
            taskName = LanguageUtil.get(actionRequest.getLocale(), "private-pages");
        } else {
            taskName = LanguageUtil.get(actionRequest.getLocale(), "public-pages");
        }
    }

    return _exportImportConfigurationLocalService.addDraftExportImportConfiguration(themeDisplay.getUserId(),
            taskName, ExportImportConfigurationConstants.TYPE_EXPORT_LAYOUT, exportLayoutSettingsMap);
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ImportLayoutsMVCActionCommand.java

License:Open Source License

protected void importData(ActionRequest actionRequest, String folderName) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = ParamUtil.getLong(actionRequest, "groupId");

    FileEntry fileEntry = _exportImportHelper.getTempFileEntry(groupId, themeDisplay.getUserId(), folderName);

    try (InputStream inputStream = _dlFileEntryLocalService.getFileAsStream(fileEntry.getFileEntryId(),
            fileEntry.getVersion(), false)) {

        importData(actionRequest, fileEntry.getTitle(), inputStream);

        deleteTempFileEntry(groupId, folderName);
    }//from  w ww . j  a  va  2 s .c o m
}