Search in sources :

Example 1 with PortletPreference

use of com.ableneo.liferay.portal.setup.domain.PortletPreference in project liferay-db-setup-core by ableneo.

the class SetupPages method newPortletPreference.

private static PortletPreference newPortletPreference(String key, String value) {
    PortletPreference pref = new PortletPreference();
    pref.setKey(key);
    pref.setValue(value);
    return pref;
}
Also used : PortletPreference(com.ableneo.liferay.portal.setup.domain.PortletPreference)

Example 2 with PortletPreference

use of com.ableneo.liferay.portal.setup.domain.PortletPreference in project liferay-db-setup-core by ableneo.

the class SetupPages method insertPortletIntoPage.

private static void insertPortletIntoPage(final PageType page, final Layout layout, final PagePortletType portlet, final long companyId, final long groupId) throws PortalException {
    long plid = layout.getPlid();
    long ownerId = PortletKeys.PREFS_OWNER_ID_DEFAULT;
    int ownerType = PortletKeys.PREFS_OWNER_TYPE_LAYOUT;
    long runAsUserId = SetupConfigurationThreadLocal.getRunAsUserId();
    LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
    String portletId = portlet.getPortletId();
    String column = portlet.getColumn();
    String portletIdInc = "";
    try {
        int columnPos = portlet.getColumnPosition();
        portletIdInc = layoutTypePortlet.addPortletId(runAsUserId, portletId, column, columnPos, false);
        if (portletIdInc == null) {
            portletIdInc = portletId;
        }
    } catch (SystemException e) {
        LOG.error("Add wrappedPortlet error ", e);
    }
    javax.portlet.PortletPreferences preferences = PortletPreferencesLocalServiceUtil.getPreferences(companyId, ownerId, ownerType, plid, portletIdInc);
    List<PortletPreference> prefsList = portlet.getPortletPreference();
    for (PortletPreference p : prefsList) {
        try {
            preferences.setValue(p.getKey(), resolvePortletPrefValue(p.getKey(), p.getValue(), portlet, companyId, groupId));
        } catch (ReadOnlyException e) {
            LOG.error("Portlet preferences (" + p.getKey() + ", " + p.getValue() + ") of " + "wrappedPortlet " + portlet.getPortletId() + " caused an excpetion! ");
        }
    }
    PortletPreferencesLocalServiceUtil.updatePreferences(ownerId, ownerType, plid, portletIdInc, preferences);
    if (Validator.isNotNull(column) && Validator.isNotNull(portletIdInc)) {
        layoutTypePortlet.movePortletId(runAsUserId, portletIdInc, column, portlet.getColumnPosition());
    }
    LayoutLocalServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings());
    if (portlet.getRolePermissions() != null) {
        LOG.info(" i portlet rights");
        updatePortletDisplayPermissions(portlet, portletIdInc, layout, page, companyId, groupId, portlet.getRolePermissions(), getDefaultPortletPermissions(layout.isPrivateLayout()));
    }
    LOG.info(" i portlet added.");
}
Also used : PortletPreference(com.ableneo.liferay.portal.setup.domain.PortletPreference) LayoutTypePortlet(com.liferay.portal.kernel.model.LayoutTypePortlet) SystemException(com.liferay.portal.kernel.exception.SystemException) ReadOnlyException(javax.portlet.ReadOnlyException)

Aggregations

PortletPreference (com.ableneo.liferay.portal.setup.domain.PortletPreference)2 SystemException (com.liferay.portal.kernel.exception.SystemException)1 LayoutTypePortlet (com.liferay.portal.kernel.model.LayoutTypePortlet)1 ReadOnlyException (javax.portlet.ReadOnlyException)1