# HG changeset patch # User Bjoern Ricks # Date 1345729972 0 # Node ID 20f12944c71062c7e4275380906595734870687f # Parent f456d9d555413434b1bb0d57fbead2ebeb3d3303 Add user account information when creating a user in the artifact database artifacts/trunk@5247 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f456d9d55541 -r 20f12944c710 ChangeLog --- a/ChangeLog Thu Aug 23 13:45:16 2012 +0000 +++ b/ChangeLog Thu Aug 23 13:52:52 2012 +0000 @@ -1,3 +1,8 @@ +2012-08-23 Björn Ricks + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: + Add account information to createUser + 2012-08-23 Björn Ricks * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: diff -r f456d9d55541 -r 20f12944c710 artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Aug 23 13:45:16 2012 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Aug 23 13:52:52 2012 +0000 @@ -197,6 +197,10 @@ public static final String XPATH_USERROLE = "/art:action/art:user/art:role"; + /** XPath to figure out the role of a new user.*/ + public static final String XPATH_USERACCOUNT = + "/art:action/art:user/art:account/@name"; + /** Error message if a specified user does not exist.*/ public static final String NO_SUCH_USER = "No such user"; @@ -205,6 +209,10 @@ public static final String NO_USERNAME = "Invalid username"; + /** Error message if no user account is given for user creation.*/ + public static final String NO_USERACCOUNT = + "Invalid user account name"; + // Collection constants /** @@ -1241,6 +1249,14 @@ throw new ArtifactDatabaseException(NO_USERNAME); } + String account = XMLUtils.xpathString( + data, XPATH_USERACCOUNT, ArtifactNamespaceContext.INSTANCE); + + if (name == null || name.length() == 0) { + logger.warn("User without account not accepted!"); + throw new ArtifactDatabaseException(NO_USERACCOUNT); + } + Node tmp = (Node) XMLUtils.xpath( data, XPATH_USERROLE, @@ -1257,7 +1273,7 @@ User newUser = null; try { - newUser = backend.createUser(name, role, userFactory, context); + newUser = backend.createUser(name, account, role, userFactory, context); } catch (Exception e) { logger.error(e.getMessage(), e);