Mercurial > dive4elements > framework
changeset 152:7e5619115d5b
Implemented the deleteUser() method in the artifact server.
artifacts/trunk@1377 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 03 Mar 2011 08:07:28 +0000 |
parents | 3d70de111af1 |
children | bf596b83d984 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java |
diffstat | 2 files changed, 35 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Mar 03 08:04:57 2011 +0000 +++ b/ChangeLog Thu Mar 03 08:07:28 2011 +0000 @@ -1,3 +1,10 @@ +2011-03-03 Ingo Weinzierl <ingo@intevation.de> + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: + Implemented the deleteUser() interface method. This operation will now + remove the specified user, its collections and the artifacts stored in + these collections. + 2011-03-03 Ingo Weinzierl <ingo@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 08:04:57 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 08:07:28 2011 +0000 @@ -176,6 +176,10 @@ public static final String XPATH_USERROLE = "/art:action/art:user/art:role"; + /** Error message if a specified user does not exist.*/ + public static final String NO_SUCH_USER = + "No such user"; + /** Error message if no username is given for user creation.*/ public static final String NO_USERNAME = "Invalid username"; @@ -961,6 +965,7 @@ for (User user: users) { Element ue = ec.create("user"); + ec.addAttr(ue, "uuid", user.identifier()); ec.addAttr(ue, "name", user.getName()); // TODO append the role of the user. @@ -1022,8 +1027,29 @@ } public Document deleteUser(String userId, 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 toDelete = factory.getUser(userId, context); + + if (toDelete == null) { + logger.warn("There is no user with the uuid: " + userId); + throw new ArtifactDatabaseException(NO_SUCH_USER); + } + + logger.debug( + "Remove user: " + toDelete.getName() + + "(" + toDelete.identifier() + ")"); + + factory.deleteUser(toDelete, context); + + // FIXME Return a useful document! + return XMLUtils.newDocument(); }