Example usage for com.liferay.portal.kernel.util ParamUtil getStringValues

List of usage examples for com.liferay.portal.kernel.util ParamUtil getStringValues

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ParamUtil getStringValues.

Prototype

public static String[] getStringValues(ServiceContext serviceContext, String param) 

Source Link

Document

Returns the service context parameter value as a String array.

Usage

From source file:com.liferay.adaptive.media.web.internal.portlet.action.DeleteImageConfigurationEntryMVCActionCommand.java

License:Open Source License

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

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

    String[] deleteAdaptiveMediaImageConfigurationEntryUuids = ParamUtil.getStringValues(actionRequest,
            "rowIdsAdaptiveMediaImageConfigurationEntry");

    List<AdaptiveMediaImageConfigurationEntry> deletedConfigurationEntries = new ArrayList<>();

    for (String deleteAdaptiveMediaImageConfigurationEntryUuid : deleteAdaptiveMediaImageConfigurationEntryUuids) {

        Optional<AdaptiveMediaImageConfigurationEntry> configurationEntryOptional = _adaptiveMediaImageConfigurationHelper
                .getAdaptiveMediaImageConfigurationEntry(themeDisplay.getCompanyId(),
                        deleteAdaptiveMediaImageConfigurationEntryUuid);

        _adaptiveMediaImageConfigurationHelper.deleteAdaptiveMediaImageConfigurationEntry(
                themeDisplay.getCompanyId(), deleteAdaptiveMediaImageConfigurationEntryUuid);

        configurationEntryOptional.ifPresent(deletedConfigurationEntries::add);
    }//ww w  .  j  a va  2s.co m

    SessionMessages.add(actionRequest, "configurationEntriesDeleted", deletedConfigurationEntries);
}

From source file:com.liferay.adaptive.media.web.internal.portlet.action.InfoPanelMVCResourceCommand.java

License:Open Source License

private List<AdaptiveMediaImageConfigurationEntry> _getSelectedAdaptiveMediaImageConfigurationEntries(
        ResourceRequest resourceRequest) {

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

    String[] rowIdsAdaptiveMediaImageConfigurationEntry = ParamUtil.getStringValues(resourceRequest,
            "rowIdsAdaptiveMediaImageConfigurationEntry");

    List<AdaptiveMediaImageConfigurationEntry> configurationEntries = new ArrayList<>();

    for (String entryUuid : rowIdsAdaptiveMediaImageConfigurationEntry) {
        Optional<AdaptiveMediaImageConfigurationEntry> configurationEntryOptional = _adaptiveMediaImageConfigurationHelper
                .getAdaptiveMediaImageConfigurationEntry(themeDisplay.getCompanyId(), entryUuid);

        configurationEntryOptional.ifPresent(configurationEntries::add);
    }//  w w w . j a v a2  s .  com

    return configurationEntries;
}

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

License:Open Source License

private void _processExportAndPublishAction(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortalException {

    String[] exportingEntities;//from w w  w . j av  a 2  s . c  o  m

    if (Validator.isNotNull(actionRequest.getParameter("exportingEntities"))) {

        exportingEntities = ParamUtil.getStringValues(actionRequest, "exportingEntities");
    } else if (Validator.isNotNull(actionRequest.getParameter("classNameId"))
            && Validator.isNotNull(actionRequest.getParameter("uuid"))) {

        long classNameId = ParamUtil.getLong(actionRequest, "classNameId");
        long groupId = ParamUtil.getLong(actionRequest, "groupId");
        String uuid = ParamUtil.getString(actionRequest, "uuid");

        StringBundler sb = new StringBundler(5);

        sb.append(classNameId);
        sb.append(StringPool.POUND);
        sb.append(groupId);
        sb.append(StringPool.POUND);
        sb.append(uuid);

        exportingEntities = new String[] { sb.toString() };
    } else {
        SessionErrors.add(actionRequest, ExportImportEntityException.class,
                new ExportImportEntityException(ExportImportEntityException.TYPE_NO_DATA_FOUND));

        return;
    }

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

    parameterMap.put("exportingEntities", exportingEntities);

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

    String cmd = ParamUtil.getString(actionRequest, "cmd");

    String portletId = MapUtil.getString(actionRequest.getParameterMap(), "portletId");

    Portlet portlet = _portletLocalService.getPortletById(portletId);

    long backgroundTaskId = 0;

    if (cmd.equals(Constants.EXPORT)) {
        Map<String, Serializable> settingsMap = ExportImportConfigurationSettingsMapFactory
                .buildExportPortletSettingsMap(themeDisplay.getUser(), themeDisplay.getPlid(),
                        themeDisplay.getScopeGroupId(), ChangesetPortletKeys.CHANGESET, parameterMap,
                        _exportImportHelper.getPortletExportFileName(portlet));

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

        backgroundTaskId = _exportImportLocalService
                .exportPortletInfoAsFileInBackground(themeDisplay.getUserId(), exportImportConfiguration);
    } else if (cmd.equals(Constants.PUBLISH)) {
        Group scopeGroup = themeDisplay.getScopeGroup();

        if (!scopeGroup.isStagingGroup() && !scopeGroup.isStagedRemotely()) {

            SessionErrors.add(actionRequest, ExportImportEntityException.class,
                    new ExportImportEntityException(ExportImportEntityException.TYPE_GROUP_NOT_STAGED));

            return;
        }

        if (!scopeGroup.isStagedPortlet(portletId)) {
            SessionErrors.add(actionRequest, ExportImportEntityException.class,
                    new ExportImportEntityException(ExportImportEntityException.TYPE_PORTLET_NOT_STAGED));

            return;
        }

        long liveGroupId = 0;

        if (scopeGroup.isStagingGroup()) {
            liveGroupId = scopeGroup.getLiveGroupId();
        } else if (scopeGroup.isStagedRemotely()) {
            liveGroupId = scopeGroup.getRemoteLiveGroupId();
        }

        Map<String, Serializable> settingsMap = ExportImportConfigurationSettingsMapFactory
                .buildPublishPortletSettingsMap(themeDisplay.getUser(), themeDisplay.getScopeGroupId(),
                        themeDisplay.getPlid(), liveGroupId, themeDisplay.getPlid(),
                        ChangesetPortletKeys.CHANGESET, parameterMap);

        ExportImportConfiguration exportImportConfiguration = _exportImportConfigurationLocalService
                .addDraftExportImportConfiguration(themeDisplay.getUserId(), portletId,
                        ExportImportConfigurationConstants.TYPE_PUBLISH_PORTLET, settingsMap);

        backgroundTaskId = _staging.publishPortlet(themeDisplay.getUserId(), exportImportConfiguration);
    }

    sendRedirect(actionRequest, actionResponse, backgroundTaskId);
}

From source file:com.liferay.journal.web.internal.display.context.JournalMoveEntriesDisplayContext.java

License:Open Source License

public List<JournalArticle> getMoveArticles() throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) _liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    List<JournalArticle> articles = new ArrayList<>();

    String[] articleIds = ParamUtil.getStringValues(_liferayPortletRequest, "rowIdsJournalArticle");

    for (String articleId : articleIds) {
        JournalArticle article = JournalArticleServiceUtil.fetchArticle(themeDisplay.getScopeGroupId(),
                articleId);//from   w  w  w  . j  a  v  a 2s .  co  m

        if (article != null) {
            articles.add(article);
        }
    }

    return articles;
}

From source file:com.liferay.journal.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static List<JournalArticle> getArticles(ResourceRequest request) throws Exception {

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

    String[] articleIds = ParamUtil.getStringValues(request, "rowIdsJournalArticle");

    List<JournalArticle> articles = new ArrayList<>();

    for (String articleId : articleIds) {
        JournalArticle article = JournalArticleServiceUtil.getArticle(groupId, articleId);

        articles.add(article);/*from   w  w  w .  java 2s  .c  o m*/
    }

    return articles;
}

From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java

License:Open Source License

public void expireEntries(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long[] expireFolderIds = ParamUtil.getLongValues(actionRequest, "rowIdsJournalFolder");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(JournalArticle.class.getName(),
            actionRequest);//from  w  w w . j  a  v a2 s.c om

    for (long expireFolderId : expireFolderIds) {
        ActionUtil.expireFolder(themeDisplay.getScopeGroupId(), expireFolderId, serviceContext);
    }

    String[] expireArticleIds = ParamUtil.getStringValues(actionRequest, "rowIdsJournalArticle");

    for (String expireArticleId : expireArticleIds) {
        ActionUtil.expireArticle(actionRequest, HtmlUtil.unescape(expireArticleId));
    }

    sendEditEntryRedirect(actionRequest, actionResponse);
}

From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java

License:Open Source License

public void moveEntries(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long[] folderIds = ParamUtil.getLongValues(actionRequest, "rowIdsJournalFolder");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(JournalArticle.class.getName(),
            actionRequest);/* w w  w .  ja  v  a2 s.c  o  m*/

    for (long folderId : folderIds) {
        _journalFolderService.moveFolder(folderId, newFolderId, serviceContext);
    }

    List<String> invalidArticleIds = new ArrayList<>();

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

    String[] articleIds = ParamUtil.getStringValues(actionRequest, "rowIdsJournalArticle");

    for (String articleId : articleIds) {
        try {
            _journalArticleService.moveArticle(themeDisplay.getScopeGroupId(), HtmlUtil.unescape(articleId),
                    newFolderId, serviceContext);
        } catch (InvalidDDMStructureException iddmse) {
            if (_log.isWarnEnabled()) {
                _log.warn(iddmse.getMessage());
            }

            invalidArticleIds.add(articleId);
        }
    }

    if (!invalidArticleIds.isEmpty()) {
        StringBundler sb = new StringBundler(4);

        sb.append("Folder ");
        sb.append(newFolderId);
        sb.append(" does not allow the structures for articles: ");
        sb.append(StringUtil.merge(invalidArticleIds));

        throw new InvalidDDMStructureException(sb.toString());
    }

    sendEditEntryRedirect(actionRequest, actionResponse);
}

From source file:com.liferay.journal.web.internal.portlet.JournalPortlet.java

License:Open Source License

protected void deleteEntries(ActionRequest actionRequest, ActionResponse actionResponse, boolean moveToTrash)
        throws Exception {

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

    List<TrashedModel> trashedModels = new ArrayList<>();

    long[] deleteFolderIds = ParamUtil.getLongValues(actionRequest, "rowIdsJournalFolder");

    for (long deleteFolderId : deleteFolderIds) {
        if (moveToTrash) {
            JournalFolder folder = _journalFolderService.moveFolderToTrash(deleteFolderId);

            trashedModels.add(folder);// ww w.j a v  a  2 s . com
        } else {
            _journalFolderService.deleteFolder(deleteFolderId);
        }
    }

    String[] deleteArticleIds = ParamUtil.getStringValues(actionRequest, "rowIdsJournalArticle");

    for (String deleteArticleId : deleteArticleIds) {
        if (moveToTrash) {
            JournalArticle article = _journalArticleService.moveArticleToTrash(themeDisplay.getScopeGroupId(),
                    HtmlUtil.unescape(deleteArticleId));

            trashedModels.add(article);
        } else {
            ActionUtil.deleteArticle(actionRequest, HtmlUtil.unescape(deleteArticleId));
        }
    }

    if (moveToTrash && !trashedModels.isEmpty()) {
        TrashUtil.addTrashSessionMessages(actionRequest, trashedModels);

        hideDefaultSuccessMessage(actionRequest);
    }

    sendEditEntryRedirect(actionRequest, actionResponse);
}

From source file:com.liferay.layout.admin.web.internal.portlet.action.DeleteOrphanPortletsMVCActionCommand.java

License:Open Source License

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

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

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

    String[] portletIds = null;//from w ww  .  ja v a  2  s . c om

    String portletId = ParamUtil.getString(actionRequest, "portletId");

    if (Validator.isNotNull(portletId)) {
        portletIds = new String[] { portletId };
    } else {
        portletIds = ParamUtil.getStringValues(actionRequest, "rowIds");
    }

    if (portletIds.length > 0) {
        _portletLocalService.deletePortlets(themeDisplay.getCompanyId(), portletIds, selPlid);
    }
}

From source file:com.liferay.portlet.configuration.web.internal.portlet.PortletConfigurationPortlet.java

License:Open Source License

public void deleteArchivedSetups(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    Portlet portlet = ActionUtil.getPortlet(actionRequest);

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

    String[] names = null;/*from   w  w  w .java 2s . c  o  m*/

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

    if (Validator.isNotNull(name)) {
        names = new String[] { name };
    } else {
        names = ParamUtil.getStringValues(actionRequest, "rowIds");
    }

    for (String curName : names) {
        ArchivedSettings archivedSettings = SettingsFactoryUtil.getPortletInstanceArchivedSettings(
                themeDisplay.getSiteGroupId(), portlet.getRootPortletId(), curName);

        archivedSettings.delete();
    }
}