felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J.W. Janssen (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (FELIX-4399) UserAdmin MongoDB plugin cannot return role when properties or members is null
Date Thu, 23 Jan 2014 09:27:37 GMT

     [ https://issues.apache.org/jira/browse/FELIX-4399?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

J.W. Janssen resolved FELIX-4399.
---------------------------------

    Resolution: Fixed

Committed fix in rev #1560612. Added a MongoDB integration test to cover this.

> UserAdmin MongoDB plugin cannot return role when properties or members is null
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-4399
>                 URL: https://issues.apache.org/jira/browse/FELIX-4399
>             Project: Felix
>          Issue Type: Bug
>          Components: User Admin
>         Environment: MongoDB 32-bit, v2.4.9
> Java 1.7
> UserAdmin 1.0.3
>            Reporter: Alec de Zegher
>            Assignee: J.W. Janssen
>   Original Estimate: 5m
>  Remaining Estimate: 5m
>
> When fetching a role with no properties or roles from mongodb, a null object is returned
by the DB. This causes a null pointer exception and as a result no roles are returned.
> This can be solved by modifying following three methods in MongoSerializerHelper.java
to:
>     /**
>      * Deserializes the given {@link DBObject} into the given {@link Dictionary}.
>      * 
>      * @param dictionary the dictionary to fill;
>      * @param object the {@link DBObject} to deserialize.
>      */
>     private void deserializeDictionary(Dictionary dictionary, DBObject object) {
>         if(object != null) {
> 	    	for (String key : object.keySet()) {
> 	            dictionary.put(KeyCodec.decode(key), object.get(key));
> 	        }
>         }
>     }
>     
>     /**
>      * Serializes a given array of {@link Role}s to an list for storing in a {@link DBObject}.
>      * 
>      * @param members the {@link Role}s to serialize, cannot be <code>null</code>.
>      * @return the "serialized" array, never <code>null</code>.
>      */
>     private List<String> getRoleNames(Role[] members) {
>         List<String> result = new ArrayList<String>();
>         if (members != null) {
>             for (Role member : members) {
>                 result.add(member.getName());
>             }
>         }
>         return result;
>     }
>     
>     /**
>      * Returns all roles mentioned in the given list.
>      * 
>      * @param list the list with role names to convert.
>      * @return a list with {@link Role}s, never <code>null</code>.
>      */
>     private List<Role> getRoles(BasicDBList list) {
>         List<Role> result = new ArrayList<Role>();
>         if(list !=null) {
> 	        for (int i = 0, size = list.size(); i < size; i++) {
> 	            final String memberName = (String) list.get(i);
> 	            result.add(findExistingMember(memberName));
> 	        }
>         }
>         return result;
>     }



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message