Example usage for com.liferay.portal.kernel.util MapUtil merge

List of usage examples for com.liferay.portal.kernel.util MapUtil merge

Introduction

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

Prototype

public static <K, V> void merge(Map<? extends K, ? extends V> master, Map<? super K, ? super V> copy) 

Source Link

Usage

From source file:XXController.java

License:LGPL

 public String genStr(PortletRequest portletRequest)
 {
   ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
   String portletName = PortalUtil.getPortletId(portletRequest);
   long plid = themeDisplay.getPlid();
   // Create and form a new request by the parameters.
   PortletURL aPortletURL = PortletURLFactoryUtil.create(portletRequest,portletName, plid, PortletRequest.RENDER_PHASE);
   Map<String, String[]> params = new LinkedHashMap<String, String[]>();
   // RenderMapping request, forward the add.jsp page.
   params.put("addUserRender", new String[] { "toAddUserPage" });
   MapUtil.merge(aPortletURL.getParameterMap(), params);
   aPortletURL.setParameters(params);/*from  w w w . jav  a  2s  .c  o m*/
   return aPortletURL.toString();
}

From source file:com.liferay.content.targeting.service.test.lar.BasePortletExportImportTestCase.java

License:Open Source License

protected void exportImportPortlet(String portletId, Map<String, String[]> exportParameterMap,
        Map<String, String[]> importParameterMap) throws Exception {

    MapUtil.merge(getExportParameterMap(), exportParameterMap);

    larFile = LayoutLocalServiceUtil.exportPortletInfoAsFile(layout.getPlid(), layout.getGroupId(), portletId,
            exportParameterMap, null, null);

    importedLayout = LayoutTestUtil.addLayout(importedGroup.getGroupId(), ServiceTestUtil.randomString());

    MapUtil.merge(getImportParameterMap(), importParameterMap);

    LayoutLocalServiceUtil.importPortletInfo(TestPropsValues.getUserId(), importedLayout.getPlid(),
            importedGroup.getGroupId(), portletId, importParameterMap, larFile);
}

From source file:com.liferay.exportimport.test.util.lar.BasePortletExportImportTestCase.java

License:Open Source License

protected void exportImportPortlet(String portletId, Map<String, String[]> exportParameterMap,
        Map<String, String[]> importParameterMap) throws Exception {

    User user = TestPropsValues.getUser();

    MapUtil.merge(getExportParameterMap(), exportParameterMap);

    Map<String, Serializable> settingsMap = ExportImportConfigurationSettingsMapFactory
            .buildExportPortletSettingsMap(user, layout.getPlid(), layout.getGroupId(), portletId,
                    exportParameterMap, StringPool.BLANK);

    ExportImportConfiguration exportImportConfiguration = ExportImportConfigurationLocalServiceUtil
            .addDraftExportImportConfiguration(user.getUserId(),
                    ExportImportConfigurationConstants.TYPE_PUBLISH_PORTLET, settingsMap);

    ExportImportThreadLocal.setPortletStagingInProcess(true);

    ExportImportLifecycleManagerUtil.fireExportImportLifecycleEvent(EVENT_PUBLICATION_PORTLET_LOCAL_STARTED,
            PROCESS_FLAG_PORTLET_STAGING_IN_PROCESS,
            String.valueOf(exportImportConfiguration.getExportImportConfigurationId()),
            exportImportConfiguration);//from  w w  w .  j ava  2s.  c  o  m

    try {
        larFile = ExportImportLocalServiceUtil.exportPortletInfoAsFile(exportImportConfiguration);

        importedLayout = LayoutTestUtil.addLayout(importedGroup);

        MapUtil.merge(getImportParameterMap(), importParameterMap);

        settingsMap = ExportImportConfigurationSettingsMapFactory.buildImportPortletSettingsMap(user,
                importedLayout.getPlid(), importedGroup.getGroupId(), portletId, importParameterMap);

        exportImportConfiguration = ExportImportConfigurationLocalServiceUtil.updateExportImportConfiguration(
                user.getUserId(), exportImportConfiguration.getExportImportConfigurationId(), StringPool.BLANK,
                StringPool.BLANK, settingsMap, new ServiceContext());

        exportImportConfiguration.setGroupId(importedGroup.getGroupId());

        exportImportConfiguration = ExportImportConfigurationLocalServiceUtil
                .updateExportImportConfiguration(exportImportConfiguration);

        ExportImportLocalServiceUtil.importPortletDataDeletions(exportImportConfiguration, larFile);

        ExportImportLocalServiceUtil.importPortletInfo(exportImportConfiguration, larFile);

        ExportImportLifecycleManagerUtil.fireExportImportLifecycleEvent(
                EVENT_PUBLICATION_PORTLET_LOCAL_SUCCEEDED, PROCESS_FLAG_PORTLET_STAGING_IN_PROCESS,
                String.valueOf(exportImportConfiguration.getExportImportConfigurationId()),
                exportImportConfiguration);
    } finally {
        ExportImportThreadLocal.setPortletStagingInProcess(false);
    }
}

From source file:com.liferay.journal.exportimport.data.handler.test.JournalExportImportTest.java

License:Open Source License

@Override
protected Map<String, String[]> getExportParameterMap() throws Exception {
    Map<String, String[]> parameterMap = super.getExportParameterMap();

    MapUtil.merge(parameterMap, getBaseParameterMap(group.getGroupId(), layout.getPlid()));

    parameterMap.put(PortletDataHandlerKeys.PORTLET_DATA + StringPool.UNDERLINE + JournalPortletKeys.JOURNAL,
            new String[] { Boolean.TRUE.toString() });

    return parameterMap;
}

From source file:com.liferay.journal.exportimport.data.handler.test.JournalExportImportTest.java

License:Open Source License

@Override
protected Map<String, String[]> getImportParameterMap() throws Exception {
    Map<String, String[]> parameterMap = super.getImportParameterMap();

    MapUtil.merge(parameterMap, getBaseParameterMap(importedGroup.getGroupId(), importedLayout.getPlid()));

    parameterMap.put(PortletDataHandlerKeys.DATA_STRATEGY,
            new String[] { PortletDataHandlerKeys.DATA_STRATEGY_MIRROR });
    parameterMap.put(PortletDataHandlerKeys.DELETE_PORTLET_DATA, new String[] { Boolean.FALSE.toString() });
    parameterMap.put(PortletDataHandlerKeys.USER_ID_STRATEGY, new String[] { UserIdStrategy.CURRENT_USER_ID });

    return parameterMap;
}

From source file:com.liferay.taglib.portlet.ActionURLTag.java

License:Open Source License

public static void doTag(String lifecycle, String windowState, String portletMode, String var, String varImpl,
        Boolean secure, Boolean copyCurrentRenderParameters, Boolean escapeXml, String name, String resourceID,
        String cacheability, long plid, long refererPlid, String portletName, Boolean anchor, Boolean encrypt,
        long doAsGroupId, long doAsUserId, Boolean portletConfiguration, Map<String, String[]> params,
        PageContext pageContext) throws Exception {

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    if (portletName == null) {
        portletName = _getPortletName(request);
    }//from  w  ww.  j ava 2  s.co  m

    LiferayPortletURL liferayPortletURL = _getLiferayPortletURL(request, plid, portletName, lifecycle);

    if (liferayPortletURL == null) {
        _log.error("Render response is null because this tag is not being "
                + "called within the context of a portlet");

        return;
    }

    if (Validator.isNotNull(windowState)) {
        liferayPortletURL.setWindowState(WindowStateFactory.getWindowState(windowState));
    }

    if (Validator.isNotNull(portletMode)) {
        liferayPortletURL.setPortletMode(PortletModeFactory.getPortletMode(portletMode));
    }

    if (secure != null) {
        liferayPortletURL.setSecure(secure.booleanValue());
    } else {
        liferayPortletURL.setSecure(PortalUtil.isSecure(request));
    }

    if (copyCurrentRenderParameters != null) {
        liferayPortletURL.setCopyCurrentRenderParameters(copyCurrentRenderParameters.booleanValue());
    }

    if (escapeXml != null) {
        liferayPortletURL.setEscapeXml(escapeXml.booleanValue());
    }

    if (lifecycle.equals(PortletRequest.ACTION_PHASE) && Validator.isNotNull(name)) {

        liferayPortletURL.setParameter(ActionRequest.ACTION_NAME, name);
    }

    if (resourceID != null) {
        liferayPortletURL.setResourceID(resourceID);
    }

    if (cacheability != null) {
        liferayPortletURL.setCacheability(cacheability);
    }

    if (refererPlid > LayoutConstants.DEFAULT_PLID) {
        liferayPortletURL.setRefererPlid(refererPlid);
    }

    if (anchor != null) {
        liferayPortletURL.setAnchor(anchor.booleanValue());
    }

    if (encrypt != null) {
        liferayPortletURL.setEncrypt(encrypt.booleanValue());
    }

    if (doAsGroupId > 0) {
        liferayPortletURL.setDoAsGroupId(doAsGroupId);
    }

    if (doAsUserId > 0) {
        liferayPortletURL.setDoAsUserId(doAsUserId);
    }

    if ((portletConfiguration != null) && portletConfiguration.booleanValue()) {

        String returnToFullPageURL = ParamUtil.getString(request, "returnToFullPageURL");
        String portletResource = ParamUtil.getString(request, "portletResource");
        String previewWidth = ParamUtil.getString(request, "previewWidth");

        liferayPortletURL.setParameter("struts_action", "/portlet_configuration/edit_configuration");
        liferayPortletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
        liferayPortletURL.setParameter("portletResource", portletResource);
        liferayPortletURL.setParameter("previewWidth", previewWidth);
    }

    if (params != null) {
        MapUtil.merge(liferayPortletURL.getParameterMap(), params);

        liferayPortletURL.setParameters(params);
    }

    String portletURLToString = liferayPortletURL.toString();

    if (Validator.isNotNull(var)) {
        pageContext.setAttribute(var, portletURLToString);
    } else if (Validator.isNotNull(varImpl)) {
        pageContext.setAttribute(varImpl, liferayPortletURL);
    } else {
        JspWriter jspWriter = pageContext.getOut();

        jspWriter.write(portletURLToString);
    }
}