comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 153:bf596b83d984

Adjusted method signatures for deleting users in the UserFactory and in the Backend. artifacts/trunk@1378 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 03 Mar 2011 08:51:02 +0000
parents 7e5619115d5b
children 1a72f08ce8d7
comparison
equal deleted inserted replaced
152:7e5619115d5b 153:bf596b83d984
53 public class ArtifactDatabaseImpl 53 public class ArtifactDatabaseImpl
54 implements ArtifactDatabase, Id.Filter, Backend.FactoryLookup 54 implements ArtifactDatabase, Id.Filter, Backend.FactoryLookup
55 { 55 {
56 private static Logger logger = 56 private static Logger logger =
57 Logger.getLogger(ArtifactDatabaseImpl.class); 57 Logger.getLogger(ArtifactDatabaseImpl.class);
58
59 /** Message that is returned if an operation was successful.*/
60 public static final String OPERATION_SUCCESSFUL =
61 "SUCCESS";
62
63 /** Message that is returned if an operation failed.*/
64 public static final String OPERATION_FAILURE =
65 "FAILURE";
58 66
59 /** 67 /**
60 * Error message issued if a requested artifact factory 68 * Error message issued if a requested artifact factory
61 * is not registered to this database. 69 * is not registered to this database.
62 */ 70 */
1013 ArtifactNamespaceContext.NAMESPACE_PREFIX); 1021 ArtifactNamespaceContext.NAMESPACE_PREFIX);
1014 1022
1015 Element root = ec.create("result"); 1023 Element root = ec.create("result");
1016 1024
1017 if (newUser != null) { 1025 if (newUser != null) {
1018 root.setTextContent("SUCCESS"); 1026 root.setTextContent(OPERATION_SUCCESSFUL);
1019 } 1027 }
1020 else { 1028 else {
1021 root.setTextContent("FAILURE"); 1029 root.setTextContent(OPERATION_FAILURE);
1022 } 1030 }
1023 1031
1024 result.appendChild(root); 1032 result.appendChild(root);
1025 1033
1026 return result; 1034 return result;
1033 1041
1034 if (factory == null) { 1042 if (factory == null) {
1035 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); 1043 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
1036 } 1044 }
1037 1045
1038 User toDelete = factory.getUser(userId, context); 1046 logger.debug("Delete user: " + userId);
1039 1047
1040 if (toDelete == null) { 1048 Document result = XMLUtils.newDocument();
1041 logger.warn("There is no user with the uuid: " + userId); 1049
1042 throw new ArtifactDatabaseException(NO_SUCH_USER); 1050 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
1043 } 1051 result,
1044 1052 ArtifactNamespaceContext.NAMESPACE_URI,
1045 logger.debug( 1053 ArtifactNamespaceContext.NAMESPACE_PREFIX);
1046 "Remove user: " + toDelete.getName() + 1054
1047 "(" + toDelete.identifier() + ")"); 1055 Element root = ec.create("result");
1048 1056 result.appendChild(root);
1049 factory.deleteUser(toDelete, context); 1057
1050 1058 try {
1051 // FIXME Return a useful document! 1059 factory.deleteUser(userId, context);
1052 return XMLUtils.newDocument(); 1060 root.setTextContent(OPERATION_SUCCESSFUL);
1061 }
1062 catch (Exception e) {
1063 logger.error(e.getMessage(), e);
1064 root.setTextContent(OPERATION_FAILURE);
1065 }
1066
1067 return result;
1053 } 1068 }
1054 1069
1055 1070
1056 // Collection API 1071 // Collection API
1057 1072

http://dive4elements.wald.intevation.org