taylor 2002/08/19 14:40:14
Modified: src/java/org/apache/jetspeed/om/security/turbine
TurbineUserPeer.java
Log:
Patch from Amit Amte to fix bug when columns in db table don't exist in JetspeedUser
Revision Changes Path
1.3 +28 -32
jakarta-jetspeed/src/java/org/apache/jetspeed/om/security/turbine/TurbineUserPeer.java
Index: TurbineUserPeer.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/security/turbine/TurbineUserPeer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TurbineUserPeer.java 28 Jun 2002 05:37:32 -0000 1.2
+++ TurbineUserPeer.java 19 Aug 2002 21:40:13 -0000 1.3
@@ -162,7 +162,7 @@
/*
* Populates a JetspeedUser from a single row in the result set.
* The hashtable of attributes for each user is populated with columns
- * from the result set.
+ * from the result set.
*
* @param row a row containing a single user's attributes.
* @param user the JetspeedUser object to be populated.
@@ -171,24 +171,10 @@
protected static void populateUserObject(Record row, int offset, JetspeedUser
user)
throws Exception
{
- // Set values are where columns are expected. They are not
- // required to be in these positions, as we set the positions
- // immediately following.
- int idPosition = 1;
- int objectDataPosition = columnNames.length;
- for( int i=0; i<columnNames.length; i++ )
- {
- if (columnNames[i].equals(USER_ID))
- idPosition = i+1;
-
- if (columnNames[i].equals(TURBINE_OBJECTDATA))
- objectDataPosition = i+1;
- }
-
// Restore the Permanent Storage Hashtable. First the
// Hashtable is restored, then any explicit table columns
// which should be included in the Hashtable are added.
- byte[] objectData = (byte[])row.getValue(objectDataPosition).asBytes();
+ byte[] objectData = (byte[])row.getValue(OBJECTDATA).asBytes();
Hashtable tempHash = (Hashtable)ObjectUtils.deserialize(objectData);
if (tempHash == null)
{
@@ -197,37 +183,46 @@
for( int j=0; j<columnNames.length; j++ )
{
- if (! columnNames[j].equalsIgnoreCase( TURBINE_OBJECTDATA ) )
+ if (! columnNames[j].equalsIgnoreCase( OBJECTDATA ) )
{
Object obj2 = null;
- Value value = row.getValue(j+1);
- if (value.isString())
+ Value value = null;
+ try {
+ value = row.getValue(columnNames[j]);
+ } catch (Exception ex) {
+ // Column missing from the torque record ..
+ // Probable/intentional mis-match between the
+ // torque schema and db table
+ continue;
+ }
+
+ if (value.isString())
obj2 = value.asString();
- else if (value.isBigDecimal())
+ else if (value.isBigDecimal())
obj2 = value.asBigDecimal();
- else if (value.isBytes())
+ else if (value.isBytes())
obj2 = value.asBytes();
- else if (value.isDate())
+ else if (value.isDate())
obj2 = value.asDate();
- else if (value.isShort())
+ else if (value.isShort())
obj2 = new Short(value.asShort());
- else if (value.isInt())
+ else if (value.isInt())
obj2 = new Integer(value.asInt());
- else if (value.isLong())
+ else if (value.isLong())
obj2 = new Long(value.asLong());
- else if (value.isDouble())
+ else if (value.isDouble())
obj2 = new Double(value.asDouble());
- else if (value.isFloat())
+ else if (value.isFloat())
obj2 = new Float(value.asFloat());
- else if (value.isBoolean())
+ else if (value.isBoolean())
obj2 = new Boolean(value.asBoolean());
- else if (value.isTime())
+ else if (value.isTime())
obj2 = value.asTime();
- else if (value.isTimestamp())
+ else if (value.isTimestamp())
obj2 = value.asTimestamp();
- else if (value.isUtilDate())
+ else if (value.isUtilDate())
obj2 = value.asUtilDate();
- else if (value.isByte())
+ else if (value.isByte())
obj2 = new Byte(value.asByte());
if ( obj2 != null )
@@ -237,6 +232,7 @@
obj2 = value.toString();
}
+ System.out.println(columnNames[j] + ": " + obj2.toString());
tempHash.put( columnNames[j], obj2 );
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>