Renamed dbException to DatabaseException.

Change-Id: Ia568816f3337c912be3467ac16af37f71224fde3
diff --git a/src/main/java/de/ids_mannheim/korap/exceptions/dbException.java b/src/main/java/de/ids_mannheim/korap/exceptions/DatabaseException.java
similarity index 79%
rename from src/main/java/de/ids_mannheim/korap/exceptions/dbException.java
rename to src/main/java/de/ids_mannheim/korap/exceptions/DatabaseException.java
index 495971e..702bf4b 100644
--- a/src/main/java/de/ids_mannheim/korap/exceptions/dbException.java
+++ b/src/main/java/de/ids_mannheim/korap/exceptions/DatabaseException.java
@@ -8,15 +8,15 @@
  * @author hanl
  * @date 08/04/2015
  */
-public class dbException extends KustvaktException {
+public class DatabaseException extends KustvaktException {
 
-    private dbException (Object userid, Integer status, String message,
+    private DatabaseException (Object userid, Integer status, String message,
                          String args) {
         super(String.valueOf(userid), status, message, args);
     }
 
 
-    public dbException (Object userid, String target, Integer status, String message,
+    public DatabaseException (Object userid, String target, Integer status, String message,
                         String ... args) {
         this(userid, status, message, Arrays.asList(args).toString());
         AuditRecord record = new AuditRecord(AuditRecord.CATEGORY.DATABASE);
@@ -28,7 +28,7 @@
     }
 
 
-    public dbException (KustvaktException e, Integer status, String ... args) {
+    public DatabaseException (KustvaktException e, Integer status, String ... args) {
         this(e.getUserid(), e.getStatusCode(), e.getMessage(), e.getEntity());
         AuditRecord record = AuditRecord.dbRecord(e.getUserid(), status, args);
         record.setField_1(e.string());
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
index 0c0468e..b608834 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
@@ -6,7 +6,7 @@
 import de.ids_mannheim.korap.exceptions.EmptyResultException;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.dbException;
+import de.ids_mannheim.korap.exceptions.DatabaseException;
 import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
 import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.user.KorAPUser;
@@ -62,7 +62,7 @@
         }
         catch (DataAccessException e) {
             jlog.error("Could not retrieve user for name: " + username, e);
-            throw new dbException(username, "korap_users",
+            throw new DatabaseException(username, "korap_users",
                     StatusCodes.DB_GET_FAILED,
                     "Could not retrieve the user with username: " + username,
                     username);
@@ -120,7 +120,7 @@
             jlog.error(
                     "Could not update user account for user: " + user.getId(),
                     e);
-            throw new dbException(user.getId(), "korap_users",
+            throw new DatabaseException(user.getId(), "korap_users",
                     StatusCodes.DB_UPDATE_FAILED,
                     "Could not update user account for user: " + user.getId(),
                     user.toString());
@@ -208,12 +208,12 @@
         catch (DuplicateKeyException e) {
             jlog.error("Could not create user account with username: {}",
                     user.getUsername());
-            throw new dbException(user.getUsername(), "korap_users",
+            throw new DatabaseException(user.getUsername(), "korap_users",
                     StatusCodes.ENTRY_EXISTS, "Username exists.",
                     user.getUsername());
         }
         catch (DataAccessException e) {
-            throw new dbException(user.getUsername(), "korap_users",
+            throw new DatabaseException(user.getUsername(), "korap_users",
                     StatusCodes.ENTRY_EXISTS, "Username exists.",
                     user.getUsername());
         }
@@ -246,7 +246,7 @@
         catch (DataAccessException e) {
             jlog.error("Could not delete account for user: " + userid, e);
             //            throw new KorAPException(e, StatusCodes.CONNECTION_ERROR);
-            throw new dbException(userid, "korap_users",
+            throw new DatabaseException(userid, "korap_users",
                     StatusCodes.DB_DELETE_FAILED,
                     "Could not delete account for user: " + userid,
                     userid.toString());
@@ -283,7 +283,7 @@
         }
         catch (DataAccessException e) {
             jlog.error("Could not reset password for name: " + username, e);
-            throw new dbException(username, "korap_users",
+            throw new DatabaseException(username, "korap_users",
                     StatusCodes.DB_UPDATE_FAILED,
                     "Could not reset password for username: " + username,
                     username, uriToken, passphrase);
@@ -308,7 +308,7 @@
         catch (DataAccessException e) {
             jlog.error("Could not confirm registration for name " + username,
                     e);
-            throw new dbException(username, "korap_users",
+            throw new DatabaseException(username, "korap_users",
                     StatusCodes.DB_UPDATE_FAILED,
                     "Could not confirm registration for username " + username,
                     username, uriToken);
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/OAuthDb.java b/src/main/java/de/ids_mannheim/korap/handlers/OAuthDb.java
index f72140a..043b322 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/OAuthDb.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/OAuthDb.java
@@ -3,7 +3,7 @@
 import de.ids_mannheim.korap.config.ClientInfo;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.dbException;
+import de.ids_mannheim.korap.exceptions.DatabaseException;
 import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.config.Attributes;
 import de.ids_mannheim.korap.user.TokenContext;
@@ -246,7 +246,7 @@
         catch (DataAccessException e) {
             e.printStackTrace();
             jlog.error("removing client '{}' failed", info.getClient_id());
-            throw new dbException(new KustvaktException(user.getId(),
+            throw new DatabaseException(new KustvaktException(user.getId(),
                     StatusCodes.ILLEGAL_ARGUMENT, "arguments given not valid",
                     info.toJSON()), StatusCodes.CLIENT_REMOVAL_FAILURE,
                     info.toJSON());
@@ -272,7 +272,7 @@
         catch (DataAccessException e) {
             e.printStackTrace();
             jlog.error("registering client '{}' failed", info.getClient_id());
-            throw new dbException(new KustvaktException(user.getId(),
+            throw new DatabaseException(new KustvaktException(user.getId(),
                     StatusCodes.ILLEGAL_ARGUMENT, "arguments given not valid",
                     info.toJSON()), StatusCodes.CLIENT_REGISTRATION_FAILURE,
                     info.toJSON());
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java b/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
index 3f0f7e1..1bbabae 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
@@ -16,7 +16,7 @@
 import de.ids_mannheim.korap.config.Attributes;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.dbException;
+import de.ids_mannheim.korap.exceptions.DatabaseException;
 import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.interfaces.db.ResourceOperationIface;
 import de.ids_mannheim.korap.resources.KustvaktResource;
@@ -62,7 +62,7 @@
             log.error(
                     "Exception during database retrieval for ids '" + ids + "'",
                     e);
-            throw new dbException(user.getId(), "resource_store",
+            throw new DatabaseException(user.getId(), "resource_store",
                     StatusCodes.DB_GET_FAILED,
                     "Exception during database retrieval for ids '" + ids,
                     ids.toString());
@@ -85,7 +85,7 @@
         catch (DataAccessException e) {
             log.error("Exception during database update for id '"
                     + resource.getPersistentID() + "'", e);
-            throw new dbException(user.getId(), "resource_store",
+            throw new DatabaseException(user.getId(), "resource_store",
                     StatusCodes.DB_UPDATE_FAILED, "Exception during database update for id '"
                             + resource.getPersistentID(), resource.toString());
         }
@@ -205,7 +205,7 @@
         catch (DataAccessException e) {
             log.error("Exception during database store for id '"
                     + resource.getPersistentID() + "'", e);
-            throw new dbException(user.getId(), "resource_store",
+            throw new DatabaseException(user.getId(), "resource_store",
                     StatusCodes.DB_INSERT_FAILED,
                     "Exception during database store for id '"
                             + resource.getPersistentID(),
@@ -225,7 +225,7 @@
             return this.jdbcTemplate.update(sql, source);
         }
         catch (DataAccessException e) {
-            throw new dbException(user.getId(), "resource_store",
+            throw new DatabaseException(user.getId(), "resource_store",
                     StatusCodes.DB_DELETE_FAILED, "Operation DELETE failed.",
                     id);
         }
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
index ec704d5..0d6004e 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
@@ -2,7 +2,7 @@
 
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.dbException;
+import de.ids_mannheim.korap.exceptions.DatabaseException;
 import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
 import de.ids_mannheim.korap.user.User;
@@ -70,7 +70,7 @@
 
 
     @Override
-    public UserDetails get (Integer id) throws dbException {
+    public UserDetails get (Integer id) throws DatabaseException {
         String sql = "SELECT * FROM user_details WHERE id=:id;";
         MapSqlParameterSource source = new MapSqlParameterSource();
         source.addValue("id", id);
@@ -95,7 +95,7 @@
             return null;
         }
         catch (DataAccessException e) {
-            throw new dbException(-1, "userDetails",
+            throw new DatabaseException(-1, "userDetails",
                     StatusCodes.REQUEST_INVALID, "The request is invalid.",
                     String.valueOf(id));
         }
@@ -103,7 +103,7 @@
 
 
     @Override
-    public UserDetails get (User user) throws dbException {
+    public UserDetails get (User user) throws DatabaseException {
         String sql = "SELECT * FROM user_details WHERE user_id=:userid;";
         MapSqlParameterSource source = new MapSqlParameterSource();
         source.addValue("userid", user.getId());
@@ -127,7 +127,7 @@
             return null;
         }
         catch (DataAccessException e) {
-            throw new dbException(user.getId(), "userDetails",
+            throw new DatabaseException(user.getId(), "userDetails",
                     StatusCodes.REQUEST_INVALID, "The request is invalid.");
         }
     }
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
index a1d29fe..dbd3c25 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
@@ -2,7 +2,7 @@
 
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.dbException;
+import de.ids_mannheim.korap.exceptions.DatabaseException;
 import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
 import de.ids_mannheim.korap.user.User;
@@ -76,7 +76,7 @@
 
 
     @Override
-    public UserSettings get (Integer id) throws dbException {
+    public UserSettings get (Integer id) throws DatabaseException {
         String sql = "SELECT * FROM user_settings WHERE id=:id;";
         MapSqlParameterSource source = new MapSqlParameterSource();
         source.addValue("id", id);
@@ -101,7 +101,7 @@
             return null;
         }
         catch (DataAccessException e) {
-            throw new dbException(-1, "userSettings",
+            throw new DatabaseException(-1, "userSettings",
                     StatusCodes.REQUEST_INVALID, "The request is invalid.",
                     String.valueOf(id));
         }
@@ -109,7 +109,7 @@
 
 
     @Override
-    public UserSettings get (User user) throws dbException {
+    public UserSettings get (User user) throws DatabaseException {
         String sql = "SELECT * FROM user_settings WHERE user_id=:userid;";
         MapSqlParameterSource source = new MapSqlParameterSource();
         source.addValue("userid", user.getId());
@@ -134,7 +134,7 @@
             return null;
         }
         catch (DataAccessException e) {
-            throw new dbException(-1, "userSettings",
+            throw new DatabaseException(-1, "userSettings",
                     StatusCodes.REQUEST_INVALID, "The request is invalid.");
         }
     }
diff --git a/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java b/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java
index 5de3726..72b52bc 100644
--- a/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java
@@ -2,7 +2,7 @@
 
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.dbException;
+import de.ids_mannheim.korap.exceptions.DatabaseException;
 import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.interfaces.db.PolicyHandlerIface;
 import de.ids_mannheim.korap.resources.Foundry;
@@ -66,17 +66,17 @@
                 + " SELECT id, :creator, :cr, :posix, :en, :exp, :ip FROM resource_store WHERE persistent_id=:target;";
 
         if (policy.getTarget() == null)
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.NO_POLICY_TARGET, "Persistent id is missing.",
                     policy.toString());
 
         if (policy.getConditions().isEmpty())
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.NO_POLICY_CONDITION,
                     "Policy conditions are missing.");
 
         if (policy.getPermissionByte() == 0)
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.NO_POLICY_PERMISSION,
                     "Policy permissions are missing.");
 
@@ -104,7 +104,7 @@
             e.printStackTrace();
             jlog.error("Operation (INSERT) not possible for '{}' for user '{}'",
                     policy.toString(), user.getId());
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.DB_INSERT_FAILED, policy.toString());
         }
     }
@@ -203,7 +203,7 @@
                 jlog.error(
                         "Operation (SELECT) not possible for '{}' for user '{}'",
                         policy.getTarget(), user.getId());
-                throw new dbException(user.getId(), "policy_store",
+                throw new DatabaseException(user.getId(), "policy_store",
                         StatusCodes.DB_GET_FAILED,
                         "Operation (SELECT) is not possible for "
                                 + policy.getTarget() + " for user "
@@ -477,7 +477,7 @@
             jlog.error(
                     "Permission Denied for retrieval for path '{}' for user '{}'",
                     path, user.getId());
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.DB_GET_FAILED,
                     "Permission is denied for retrieval for path " + path
                             + " for user " + user.getUsername(),
@@ -537,7 +537,7 @@
             jlog.error(
                     "Permission Denied for retrieval for path '{}' for user '{}'",
                     name, user.getId());
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.DB_GET_FAILED,
                     "Permission is denied for retrieval for path " + name
                             + "for user" + user.getUsername() + ".",
@@ -567,7 +567,7 @@
         catch (DataAccessException e) {
             jlog.error("Operation (DELETE) not possible for '{}' for user '{}'",
                     policy.toString(), user.getId());
-            throw new dbException(user.getId(), "policy_store, group_ref",
+            throw new DatabaseException(user.getId(), "policy_store, group_ref",
                     StatusCodes.DB_DELETE_FAILED,
                     "Operation (DELETE) is not possible for user.",
                     policy.toString());
@@ -587,7 +587,7 @@
         catch (DataAccessException e) {
             jlog.error("Operation (DELETE) not possible for '{}' for user '{}'",
                     id, user.getId());
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.DB_DELETE_FAILED,
                     "Operation (DELETE) is not possible for user "
                             + user.getUsername(),
@@ -614,7 +614,7 @@
         catch (DataAccessException e) {
             jlog.error("Operation (UPDATE) not possible for '{}' for user '{}'",
                     policy.toString(), user.getId());
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.DB_UPDATE_FAILED,
                     "Operation (UPDATE) on " + policy.toString()
                             + " is not possible for user" + user.getUsername(),
@@ -639,7 +639,7 @@
         catch (DataAccessException e) {
             jlog.error("Operation (SELECT) not possible for '{}' for user '{}'",
                     policy.getTarget(), user.getId());
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.DB_GET_FAILED,
                     "Operation (SELECT) on " + policy.getTarget()
                             + " is not possible for user " + user.getUsername(),
@@ -683,7 +683,7 @@
         catch (DataAccessException e) {
             jlog.error("Operation (SELECT) not possible for '{}' for user '{}'",
                     group, user.getId());
-            throw new dbException(user.getId(), "policy_store",
+            throw new DatabaseException(user.getId(), "policy_store",
                     StatusCodes.DB_GET_FAILED,
                     "Operation (SELECT) is not possible for user "
                             + user.getUsername(),
@@ -709,7 +709,7 @@
         catch (DataAccessException e) {
             jlog.error("Operation (INSERT) not possible for '{}'",
                     condition.toString());
-            throw new dbException(user.getId(), "group_store",
+            throw new DatabaseException(user.getId(), "group_store",
                     StatusCodes.DB_INSERT_FAILED,
                     "Operation (INSERT) is not possible for",
                     condition.toString());
@@ -738,7 +738,7 @@
                 jlog.error(
                         "Operation (INSERT) not possible for '{}' for user '{}'",
                         condition.toString(), username);
-                throw new dbException(null, "group_store",
+                throw new DatabaseException(null, "group_store",
                         StatusCodes.DB_INSERT_FAILED,
                         "Operation (INSERT) on " + condition.toString()
                                 + " is not possible for user " + username,
diff --git a/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java b/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
index 072f702..017abba 100644
--- a/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
+++ b/src/test/java/de/ids_mannheim/korap/user/UserdataTest.java
@@ -6,7 +6,7 @@
 import de.ids_mannheim.korap.config.BeanConfigTest;
 import de.ids_mannheim.korap.config.BeansFactory;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.dbException;
+import de.ids_mannheim.korap.exceptions.DatabaseException;
 import de.ids_mannheim.korap.handlers.UserDetailsDao;
 import de.ids_mannheim.korap.handlers.UserSettingsDao;
 import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;