Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 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 | b77465617071 |
children | f4b14240ffa3 |
comparison
equal
deleted
inserted
replaced
410:f456d9d55541 | 411:20f12944c710 |
---|---|
195 | 195 |
196 /** XPath to figure out the role of a new user.*/ | 196 /** XPath to figure out the role of a new user.*/ |
197 public static final String XPATH_USERROLE = | 197 public static final String XPATH_USERROLE = |
198 "/art:action/art:user/art:role"; | 198 "/art:action/art:user/art:role"; |
199 | 199 |
200 /** XPath to figure out the role of a new user.*/ | |
201 public static final String XPATH_USERACCOUNT = | |
202 "/art:action/art:user/art:account/@name"; | |
203 | |
200 /** Error message if a specified user does not exist.*/ | 204 /** Error message if a specified user does not exist.*/ |
201 public static final String NO_SUCH_USER = | 205 public static final String NO_SUCH_USER = |
202 "No such user"; | 206 "No such user"; |
203 | 207 |
204 /** Error message if no username is given for user creation.*/ | 208 /** Error message if no username is given for user creation.*/ |
205 public static final String NO_USERNAME = | 209 public static final String NO_USERNAME = |
206 "Invalid username"; | 210 "Invalid username"; |
211 | |
212 /** Error message if no user account is given for user creation.*/ | |
213 public static final String NO_USERACCOUNT = | |
214 "Invalid user account name"; | |
207 | 215 |
208 // Collection constants | 216 // Collection constants |
209 | 217 |
210 /** | 218 /** |
211 * Error message issued if the creation of a collection failed. | 219 * Error message issued if the creation of a collection failed. |
1239 if (name == null || name.length() == 0) { | 1247 if (name == null || name.length() == 0) { |
1240 logger.warn("User without username not accepted!"); | 1248 logger.warn("User without username not accepted!"); |
1241 throw new ArtifactDatabaseException(NO_USERNAME); | 1249 throw new ArtifactDatabaseException(NO_USERNAME); |
1242 } | 1250 } |
1243 | 1251 |
1252 String account = XMLUtils.xpathString( | |
1253 data, XPATH_USERACCOUNT, ArtifactNamespaceContext.INSTANCE); | |
1254 | |
1255 if (name == null || name.length() == 0) { | |
1256 logger.warn("User without account not accepted!"); | |
1257 throw new ArtifactDatabaseException(NO_USERACCOUNT); | |
1258 } | |
1259 | |
1244 Node tmp = (Node) XMLUtils.xpath( | 1260 Node tmp = (Node) XMLUtils.xpath( |
1245 data, | 1261 data, |
1246 XPATH_USERROLE, | 1262 XPATH_USERROLE, |
1247 XPathConstants.NODE, | 1263 XPathConstants.NODE, |
1248 ArtifactNamespaceContext.INSTANCE); | 1264 ArtifactNamespaceContext.INSTANCE); |
1255 } | 1271 } |
1256 | 1272 |
1257 User newUser = null; | 1273 User newUser = null; |
1258 | 1274 |
1259 try { | 1275 try { |
1260 newUser = backend.createUser(name, role, userFactory, context); | 1276 newUser = backend.createUser(name, account, role, userFactory, context); |
1261 } | 1277 } |
1262 catch (Exception e) { | 1278 catch (Exception e) { |
1263 logger.error(e.getMessage(), e); | 1279 logger.error(e.getMessage(), e); |
1264 throw new ArtifactDatabaseException(USER_CREATION_FAILED); | 1280 throw new ArtifactDatabaseException(USER_CREATION_FAILED); |
1265 } | 1281 } |