Author: [email protected]
Date: Tue Mar 15 12:17:29 2011
New Revision: 881

Log:
[AMDATU-330] Fixed by checking propertyType super column which was removed by 
accident after the Hector API refactoring

Modified:
   
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/service/CassandraStorageProvider.java

Modified: 
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/service/CassandraStorageProvider.java
==============================================================================
--- 
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/service/CassandraStorageProvider.java
     (original)
+++ 
trunk/amdatu-cassandra/cassandra-useradminstore/src/main/java/org/amdatu/cassandra/useradminstore/service/CassandraStorageProvider.java
     Tue Mar 15 12:17:29 2011
@@ -397,6 +397,24 @@
         }
         return map;
     }
+    
+    private Map<String, Object> toMap(HSuperColumn<String, String, byte[]> 
superColumn, HSuperColumn<String, String, byte[]> superColumnTypes) throws 
StorageException, UnsupportedEncodingException {
+        Map<String, Object> map = new HashMap<String, Object>();
+        if (superColumn != null) {
+            List<HColumn<String, byte[]>> columns = superColumn.getColumns();
+            for (HColumn<String, byte[]> column : columns) {
+                String type = new 
String(getColumn(superColumnTypes.getColumns(), column.getName()).getValue(), 
"UTF-8");
+                if (STRING_TYPE.equals(type)) {
+                    map.put(column.getName(), new String(column.getValue(), 
"UTF-8"));
+                } else if (BYTES_TYPE.equals(type)) {
+                    map.put(column.getName(), column.getValue());
+                } else {
+                    throw new StorageException("Property type '" + type + "' 
is not supported.");
+                }
+            }
+        }
+        return map;
+    }
 
     // Loads a single role from Cassandra and converts it to either a User or 
a Group
     private Role internalLoadRole(UserAdminFactory factory, String key, Filter 
filter) throws StorageException {
@@ -409,9 +427,10 @@
             List<HSuperColumn<String, String, byte[]>> superColumns = 
m_pm.getSuperColumns(CF_ROLE, key, byte[].class);
             HSuperColumn<String, String, byte[]> basicSC = 
getSuperColumn(superColumns, SUPER_COLUMN_BASIC);
             HSuperColumn<String, String, byte[]> propertiesSC = 
getSuperColumn(superColumns, SUPER_COLUMN_PROPERTIES);
+            HSuperColumn<String, String, byte[]> propertyTypesSC = 
getSuperColumn(superColumns, SUPER_COLUMN_PROPERTY_TYPES);
             HSuperColumn<String, String, byte[]> credentialsSC = 
getSuperColumn(superColumns, SUPER_COLUMN_CREDENTIALS);
 
-            Map<String, Object> properties = toMap(propertiesSC);
+            Map<String, Object> properties = toMap(propertiesSC, 
propertyTypesSC);
             Map<String, Object> credentials = toMap(credentialsSC);
 
             // Verify if the filter matches the properties or credentials of 
this role
_______________________________________________
Amdatu-commits mailing list
[email protected]
http://lists.amdatu.org/mailman/listinfo/amdatu-commits

Reply via email to