changeset 411:20f12944c710

Add user account information when creating a user in the artifact database artifacts/trunk@5247 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Thu, 23 Aug 2012 13:52:52 +0000
parents f456d9d55541
children f4b14240ffa3
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java
diffstat 2 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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	<bjoern.ricks@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
+	  Add account information to createUser
+
 2012-08-23	Björn Ricks	<bjoern.ricks@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.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);

http://dive4elements.wald.intevation.org