final List<IPortletPreference> portletPreferencesList = new ArrayList<IPortletPreference>(preferencesMap.size());
for (final Entry<String, List<String>> prefEntry : preferencesMap.entrySet()) {
final String prefName = prefEntry.getKey();
final List<String> prefValues = prefEntry.getValue();
final IPortletPreference portletPreference = new PortletPreferenceImpl(prefName, false, prefValues.toArray(new String[prefValues.size()]));
portletPreferencesList.add(portletPreference);
}
//Persist the changes.
portletEntity.setPortletPreferences(portletPreferencesList);