Mercurial > dive4elements > framework
changeset 417:410a1bfb9590
Fix for NPE on empty user database
artifacts/trunk@5270 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 27 Aug 2012 08:33:05 +0000 |
parents | 733e76413bf8 |
children | 8d8aed23c323 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java artifacts/src/main/java/de/intevation/artifacts/CallContext.java |
diffstat | 3 files changed, 23 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Aug 24 14:09:53 2012 +0000 +++ b/ChangeLog Mon Aug 27 08:33:05 2012 +0000 @@ -1,3 +1,9 @@ +2012-08-27 Christian Lins <christian.lins@intevation.de> + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java, + artifacts/src/main/java/de/intevation/artifacts/CallContext.java: + Fix for NPE on empty user database. + 2012-08-24 Björn Ricks <bjoern.ricks@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/rest/RestApp.java,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Fri Aug 24 14:09:53 2012 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Mon Aug 27 08:33:05 2012 +0000 @@ -1217,23 +1217,25 @@ Element root = ec.create("users"); result.appendChild(root); + + if(users != null) { + for (User user: users) { + Element ue = ec.create("user"); + ec.addAttr(ue, "uuid", user.identifier(), true); + ec.addAttr(ue, "name", user.getName(), true); + Element ua = ec.create("account"); + ec.addAttr(ua, "name", user.getAccount(), true); + ue.appendChild(ua); - for (User user: users) { - Element ue = ec.create("user"); - ec.addAttr(ue, "uuid", user.identifier(), true); - ec.addAttr(ue, "name", user.getName(), true); - Element ua = ec.create("account"); - ec.addAttr(ua, "name", user.getAccount(), true); - ue.appendChild(ua); + Document role = user.getRole(); - Document role = user.getRole(); + if (role != null) { + ue.appendChild(result.importNode(role.getFirstChild(), true)); + } - if (role != null) { - ue.appendChild(result.importNode(role.getFirstChild(), true)); + root.appendChild(ue); + } - - root.appendChild(ue); - } return result;
--- a/artifacts/src/main/java/de/intevation/artifacts/CallContext.java Fri Aug 24 14:09:53 2012 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/CallContext.java Mon Aug 27 08:33:05 2012 +0000 @@ -8,8 +8,8 @@ package de.intevation.artifacts; +import java.util.LinkedList; import java.util.List; -import java.util.LinkedList; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -110,7 +110,7 @@ * Each call context has a clipboard. * getContextValue is used to fetch data from this board. * @param key Key of the requested item. - * @return The value stored for the secified value, null if + * @return The value stored for the specified value, null if * no item with this key exists. */ Object getContextValue(Object key);