Mercurial > dive4elements > framework
changeset 150:78a27a6b3f1f
Implemented the listUsers() method in the artifact database.
artifacts/trunk@1375 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 03 Mar 2011 07:10:44 +0000 |
parents | c69abd07bdd0 |
children | 3d70de111af1 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java |
diffstat | 2 files changed, 38 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + * 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 <ingo@intevation.de> * 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)