Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 157:6e6965873a48
Simplified creation of users.
artifacts/trunk@1382 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 03 Mar 2011 10:33:49 +0000 |
parents | f797093c60bd |
children | d718a4d55662 |
comparison
equal
deleted
inserted
replaced
156:a76de72ad6d1 | 157:6e6965873a48 |
---|---|
969 | 969 |
970 if (factory == null) { | 970 if (factory == null) { |
971 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); | 971 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); |
972 } | 972 } |
973 | 973 |
974 User[] users = factory.getUsers(context); | 974 User [] users = backend.getUsers(factory, context); |
975 | 975 |
976 if (users != null) { | 976 if (users != null) { |
977 logger.debug(users.length + " users found in the backend."); | 977 logger.debug(users.length + " users found in the backend."); |
978 } | 978 } |
979 | 979 |
1020 Document role = XMLUtils.newDocument(); | 1020 Document role = XMLUtils.newDocument(); |
1021 | 1021 |
1022 User newUser = null; | 1022 User newUser = null; |
1023 | 1023 |
1024 try { | 1024 try { |
1025 newUser = factory.createUser(name, role, context); | 1025 newUser = backend.createUser(name, role, userFactory, context); |
1026 } | 1026 } |
1027 catch (Exception e) { | 1027 catch (Exception e) { |
1028 logger.error(e.getMessage(), e); | 1028 logger.error(e.getMessage(), e); |
1029 throw new ArtifactDatabaseException(USER_CREATION_FAILED); | 1029 throw new ArtifactDatabaseException(USER_CREATION_FAILED); |
1030 } | 1030 } |
1051 } | 1051 } |
1052 | 1052 |
1053 public Document deleteUser(String userId, CallMeta callMeta) | 1053 public Document deleteUser(String userId, CallMeta callMeta) |
1054 throws ArtifactDatabaseException | 1054 throws ArtifactDatabaseException |
1055 { | 1055 { |
1056 UserFactory factory = getUserFactory(); | |
1057 | |
1058 if (factory == null) { | |
1059 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); | |
1060 } | |
1061 | |
1062 logger.debug("Delete user: " + userId); | 1056 logger.debug("Delete user: " + userId); |
1063 | 1057 |
1064 Document result = XMLUtils.newDocument(); | 1058 Document result = XMLUtils.newDocument(); |
1065 | 1059 |
1066 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( | 1060 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
1069 ArtifactNamespaceContext.NAMESPACE_PREFIX); | 1063 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
1070 | 1064 |
1071 Element root = ec.create("result"); | 1065 Element root = ec.create("result"); |
1072 result.appendChild(root); | 1066 result.appendChild(root); |
1073 | 1067 |
1074 boolean success = factory.deleteUser(userId, context); | 1068 boolean success = backend.deleteUser(userId); |
1075 | 1069 |
1076 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE); | 1070 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE); |
1077 | 1071 |
1078 return result; | 1072 return result; |
1079 } | 1073 } |