deletePrefNamesPstmt.setString(3, chanDescId);
deletePrefNamesPstmt.executeUpdate();
//Loop through the prefs, inserting each name then the values
for (Iterator prefItr = prefs.iterator(); prefItr.hasNext();) {
final Preference pref = (Preference)prefItr.next();
int prefId = -1;
insertPrefNamePstmt.setInt(1, userId);
insertPrefNamePstmt.setInt(2, layoutId);
insertPrefNamePstmt.setString(3, chanDescId);
insertPrefNamePstmt.setString(4, pref.getName());
//Use the list of removed ids to re-use IDs before generating new ones
if (prefIds.size() > 0) {
prefId = ((Integer)prefIds.removeLast()).intValue();
}
else {
final ICounterStore counterStore = CounterStoreFactory.getCounterStoreImpl();
try {
prefId = counterStore.getIncrementIntegerId(UP_PORTLET_PREFERENCE_VALUE);
}
catch (Exception e) {
counterStore.createCounter(UP_PORTLET_PREFERENCE_VALUE);
prefId = counterStore.getIncrementIntegerId(UP_PORTLET_PREFERENCE_VALUE);
}
}
insertPrefNamePstmt.setInt(5, prefId);
//Insert the name row
if (log.isDebugEnabled())
log.debug("RDBMPortletPreferencesStore::setEntityPreferences(): " + insertPrefName);
insertPrefNamePstmt.executeUpdate();
//For each value a row will be inserted in the values table
for (final Iterator valueItr = pref.getValues(); valueItr.hasNext();) {
String value = (String)valueItr.next();
if (log.isDebugEnabled())
log.debug("RDBMPortletPreferencesStore::setEntityPreferences(): " + insertPrefValue);
insertPrefValuePstmt.setInt(1, prefId);
insertPrefValuePstmt.setString(2, PREFIX + value);