# HG changeset patch # User Ingo Weinzierl # Date 1299136244 0 # Node ID 78a27a6b3f1f1ad405ec89ab03980a0faacfe2c0 # Parent c69abd07bdd087a1dd1b2d274561e72a0101b404 Implemented the listUsers() method in the artifact database. artifacts/trunk@1375 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r c69abd07bdd0 -r 78a27a6b3f1f ChangeLog --- a/ChangeLog Thu Mar 03 06:53:51 2011 +0000 +++ b/ChangeLog Thu Mar 03 07:10:44 2011 +0000 @@ -1,3 +1,9 @@ +2011-03-03 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: + Implemented the listUsers() interface method. This operation will now + return a list of users as document. + 2011-03-03 Ingo Weinzierl * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: diff -r c69abd07bdd0 -r 78a27a6b3f1f artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 06:53:51 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 07:10:44 2011 +0000 @@ -935,9 +935,39 @@ // User API public Document listUsers(CallMeta callMeta) - throws ArtifactDatabaseException { - throw new ArtifactDatabaseException("Not implemented, yet!"); + throws ArtifactDatabaseException + { + UserFactory factory = getUserFactory(); + if (factory == null) { + throw new ArtifactDatabaseException(NO_SUCH_FACTORY); + } + + User[] users = factory.getUsers(context); + + if (users != null) { + logger.debug(users.length + " users found in the backend."); + } + + Document result = XMLUtils.newDocument(); + + XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( + result, + ArtifactNamespaceContext.NAMESPACE_URI, + ArtifactNamespaceContext.NAMESPACE_PREFIX); + + Element root = ec.create("users"); + result.appendChild(root); + + for (User user: users) { + Element ue = ec.create("user"); + ec.addAttr(ue, "name", user.getName()); + + // TODO append the role of the user. + root.appendChild(ue); + } + + return result; } public Document createUser(Document data, CallMeta callMeta)