return list;
}
public ThemeStylesheetUserPreferences getThemeStylesheetUserPreferences (IPerson person, int profileId, int stylesheetId) throws Exception {
int userId = person.getID();
ThemeStylesheetUserPreferences tsup;
Connection con = RDBMServices.getConnection();
try {
Statement stmt = con.createStatement();
try {
// get stylesheet description
ThemeStylesheetDescription tsd = getThemeStylesheetDescription(stylesheetId);
// get user defined defaults
int layoutId = this.getLayoutID(userId, profileId);
ResultSet rs;
if (layoutId == 0) { // First time, grab the default layout for this user
String sQuery = "SELECT USER_DFLT_USR_ID FROM UP_USER WHERE USER_ID=" + userId;
if (log.isDebugEnabled())
log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);
rs = stmt.executeQuery(sQuery);
try {
rs.next();
userId = rs.getInt(1);
} finally {
rs.close();
}
}
String sQuery = "SELECT PARAM_NAME, PARAM_VAL FROM UP_SS_USER_PARM WHERE USER_ID=" + userId + " AND PROFILE_ID="
+ profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=2";
if (log.isDebugEnabled())
log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);
rs = stmt.executeQuery(sQuery);
try {
while (rs.next()) {
// stylesheet param
tsd.setStylesheetParameterDefaultValue(rs.getString(1), rs.getString(2));
}
} finally {
rs.close();
}
tsup = new ThemeStylesheetUserPreferences();
tsup.setStylesheetId(stylesheetId);
// fill stylesheet description with defaults
for (Enumeration e = tsd.getStylesheetParameterNames(); e.hasMoreElements();) {
String pName = (String)e.nextElement();
tsup.putParameterValue(pName, tsd.getStylesheetParameterDefaultValue(pName));
}
for (Enumeration e = tsd.getChannelAttributeNames(); e.hasMoreElements();) {
String pName = (String)e.nextElement();
tsup.addChannelAttribute(pName, tsd.getChannelAttributeDefaultValue(pName));
}
// get user preferences
sQuery = "SELECT PARAM_TYPE, PARAM_NAME, PARAM_VAL, ULS.STRUCT_ID, CHAN_ID FROM UP_SS_USER_ATTS UUSA, UP_LAYOUT_STRUCT ULS WHERE UUSA.USER_ID=" + userId + " AND PROFILE_ID="
+ profileId + " AND SS_ID=" + stylesheetId + " AND SS_TYPE=2 AND UUSA.STRUCT_ID = ULS.STRUCT_ID AND UUSA.USER_ID = ULS.USER_ID";
if (log.isDebugEnabled())
log.debug("RDBMUserLayoutStore::getThemeStylesheetUserPreferences(): " + sQuery);
rs = stmt.executeQuery(sQuery);
try {
while (rs.next()) {
int param_type = rs.getInt(1);
if (rs.wasNull()) {
param_type = 0;
}
int structId = rs.getInt(4);
if (rs.wasNull()) {
structId = 0;
}
int chanId = rs.getInt(5);
if (rs.wasNull()) {
chanId = 0;
}
if (param_type == 1) {
// stylesheet param
log.error( "RDBMUserLayoutStore::getThemeStylesheetUserPreferences() : stylesheet global params should be specified in the user defaults table ! UP_SS_USER_ATTS is corrupt. (userId="
+ Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)
+ ", param_name=\"" + rs.getString(2) + "\", param_type=" + Integer.toString(param_type));
}
else if (param_type == 2) {
// folder attribute
log.error( "RDBMUserLayoutStore::getThemeStylesheetUserPreferences() : folder attribute specified for the theme stylesheet! UP_SS_USER_ATTS corrupt. (userId="
+ Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)
+ ", param_name=\"" + rs.getString(2) + "\", param_type=" + Integer.toString(param_type));
}
else if (param_type == 3) {
// channel attribute
tsup.setChannelAttributeValue(getStructId(structId,chanId), rs.getString(2), rs.getString(3));
}
else {
// unknown param type
log.error( "RDBMUserLayoutStore::getThemeStylesheetUserPreferences() : unknown param type encountered! DB corrupt. (userId="
+ Integer.toString(userId) + ", profileId=" + Integer.toString(profileId) + ", stylesheetId=" + Integer.toString(stylesheetId)