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;
}
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.");
}
Aggregations