comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 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 78a27a6b3f1f
children bf596b83d984
comparison
equal deleted inserted replaced
151:3d70de111af1 152:7e5619115d5b
173 "/art:action/art:user/@name"; 173 "/art:action/art:user/@name";
174 174
175 /** XPath to figure out the role of a new user.*/ 175 /** XPath to figure out the role of a new user.*/
176 public static final String XPATH_USERROLE = 176 public static final String XPATH_USERROLE =
177 "/art:action/art:user/art:role"; 177 "/art:action/art:user/art:role";
178
179 /** Error message if a specified user does not exist.*/
180 public static final String NO_SUCH_USER =
181 "No such user";
178 182
179 /** Error message if no username is given for user creation.*/ 183 /** Error message if no username is given for user creation.*/
180 public static final String NO_USERNAME = 184 public static final String NO_USERNAME =
181 "Invalid username"; 185 "Invalid username";
182 186
959 Element root = ec.create("users"); 963 Element root = ec.create("users");
960 result.appendChild(root); 964 result.appendChild(root);
961 965
962 for (User user: users) { 966 for (User user: users) {
963 Element ue = ec.create("user"); 967 Element ue = ec.create("user");
968 ec.addAttr(ue, "uuid", user.identifier());
964 ec.addAttr(ue, "name", user.getName()); 969 ec.addAttr(ue, "name", user.getName());
965 970
966 // TODO append the role of the user. 971 // TODO append the role of the user.
967 root.appendChild(ue); 972 root.appendChild(ue);
968 } 973 }
1020 1025
1021 return result; 1026 return result;
1022 } 1027 }
1023 1028
1024 public Document deleteUser(String userId, CallMeta callMeta) 1029 public Document deleteUser(String userId, CallMeta callMeta)
1025 throws ArtifactDatabaseException { 1030 throws ArtifactDatabaseException
1026 throw new ArtifactDatabaseException("Not implemented, yet!"); 1031 {
1032 UserFactory factory = getUserFactory();
1033
1034 if (factory == null) {
1035 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
1036 }
1037
1038 User toDelete = factory.getUser(userId, context);
1039
1040 if (toDelete == null) {
1041 logger.warn("There is no user with the uuid: " + userId);
1042 throw new ArtifactDatabaseException(NO_SUCH_USER);
1043 }
1044
1045 logger.debug(
1046 "Remove user: " + toDelete.getName() +
1047 "(" + toDelete.identifier() + ")");
1048
1049 factory.deleteUser(toDelete, context);
1050
1051 // FIXME Return a useful document!
1052 return XMLUtils.newDocument();
1027 } 1053 }
1028 1054
1029 1055
1030 // Collection API 1056 // Collection API
1031 1057

http://dive4elements.wald.intevation.org