如何自动将 portlet 页面分发到不同的环境?

How can I distribute portlet pages to different environments automatically?

我是开发 liferay 6.1 portlet 的新手。我想要我的 portlet 所在的页面中的静态 url 和静态内容。推荐使用哪些方法将 Portlet 和页面分发到不同的环境?

我希望所有环境尽可能完全匹配,我更喜欢让一切都自动化,所以我希望页面创建也能自动进行。

您可以使用 资源导入器 ,可以在 Liferay Developer Network: Creating plugins to share structures, templates and more.

中找到相关文档

或者您通过导出页面创建 LAR 文件 - Liferay Developer Network: Export/Import.

中再次描述

您可以从 UI 或使用以下代码导入 LAR 文件:

public void importPages() {
    // Define the settings for import - here some examples:
    final Map<String, String[]> params = new HashMap<>();
    addParam(params, PortletDataHandlerKeys.PORTLET_USER_PREFERENCES, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_USER_PREFERENCES_ALL, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_CONFIGURATION, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_CONFIGURATION_ALL, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_ARCHIVED_SETUPS, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_ARCHIVED_SETUPS_ALL, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_DATA, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_DATA_ALL, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_SETUP, true);
        addParam(params, PortletDataHandlerKeys.PORTLET_SETUP_ALL, true);
    addParam(params, PortletDataHandlerKeys.PORTLET_DATA_CONTROL_DEFAULT, true);

    addParam(params, PortletDataHandlerKeys.THEME_REFERENCE, true);
    addParam(params, PortletDataHandlerKeys.LAYOUT_SET_SETTINGS, true);
    addParam(params, PortletDataHandlerKeys.LOGO, true);

    addParam(params, PortletDataHandlerKeys.CATEGORIES, true);
    addParam(params, PortletDataHandlerKeys.RATINGS, true);
    addParam(params, PortletDataHandlerKeys.COMMENTS, true);

    addParam(params, PortletDataHandlerKeys.DELETE_MISSING_LAYOUTS, true);
    addParam(params, PortletDataHandlerKeys.DELETIONS, true);
    addParam(params, PortletDataHandlerKeys.DELETE_PORTLET_DATA, true);

    addParam(params, PortletDataHandlerKeys.USER_ID_STRATEGY, UserIdStrategy.CURRENT_USER_ID);
    addParam(params, PortletDataHandlerKeys.DATA_STRATEGY, PortletDataHandlerKeys.DATA_STRATEGY_MIRROR);

    addParam(params, PortletDataHandlerKeys.PERMISSIONS, true);

    // Import with the current user into the current site (= group)
    ThemeDisplay themeDisplay = (ThemeDisplay) getPortletRequest().getAttribute(WebKeys.THEME_DISPLAY)
    LayoutLocalServiceUtil.importLayouts(themeDisplay.getUserId(), themeDisplay.getHostGroupId(), false, params, inputStreamOfMyLARFile);
}

// Helper method
private static void addParam(final Map<String, String[]> params, final String key, final Object value) {
    params.put(key, new String[] { value.toString() });
}