Remove soft delete group and group status deleted (#765).

Change-Id: I0410652d68c0e254fe70c1691b1d3b8927fbb22d
diff --git a/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
index 0a904d3..0b92706 100644
--- a/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/FullConfiguration.java
@@ -48,7 +48,6 @@
     private String authenticationScheme;
 
     private boolean isSoftDeleteAutoGroup;
-    private boolean isSoftDeleteGroup;
     private boolean isSoftDeleteGroupMember;
 
     private EncryptionIface.Encryption secureHashAlgorithm;
@@ -170,8 +169,8 @@
     }
 
     private void setDeleteConfiguration (Properties properties) {
-        setSoftDeleteGroup(
-                parseDeleteConfig(properties.getProperty("delete.group", "")));
+//        setSoftDeleteGroup(
+//                parseDeleteConfig(properties.getProperty("delete.group", "")));
         setSoftDeleteAutoGroup(parseDeleteConfig(
                 properties.getProperty("delete.auto.group", "")));
         setSoftDeleteGroupMember(parseDeleteConfig(
@@ -311,14 +310,6 @@
         this.allOnlyRegex = allOnlyRegex;
     }
 
-    public boolean isSoftDeleteGroup () {
-        return isSoftDeleteGroup;
-    }
-
-    public void setSoftDeleteGroup (boolean isSoftDeleteGroup) {
-        this.isSoftDeleteGroup = isSoftDeleteGroup;
-    }
-
     public boolean isSoftDeleteGroupMember () {
         return isSoftDeleteGroupMember;
     }
diff --git a/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java b/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java
index 03eedcb..bec7b8e 100644
--- a/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java
+++ b/src/main/java/de/ids_mannheim/korap/constant/UserGroupStatus.java
@@ -9,7 +9,7 @@
  *
  */
 public enum UserGroupStatus {
-    ACTIVE, DELETED,
+    ACTIVE, 
     // group members cannot see the group
     HIDDEN;
 }
diff --git a/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java b/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
index 5444a96..38ab977 100644
--- a/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
+++ b/src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
@@ -100,8 +100,7 @@
         return roles;
     }
 
-    public void deleteGroup (int groupId, String deletedBy,
-            boolean isSoftDelete) throws KustvaktException {
+    public void deleteGroup (int groupId, String deletedBy) throws KustvaktException {
         ParameterChecker.checkIntegerValue(groupId, "groupId");
         ParameterChecker.checkStringValue(deletedBy, "deletedBy");
 
@@ -115,17 +114,11 @@
                     "groupId: " + groupId);
         }
 
-        if (isSoftDelete) {
-            group.setStatus(UserGroupStatus.DELETED);
-            group.setDeletedBy(deletedBy);
-            entityManager.merge(group);
+        // EM: this seems weird
+        if (!entityManager.contains(group)) {
+            group = entityManager.merge(group);
         }
-        else {
-            if (!entityManager.contains(group)) {
-                group = entityManager.merge(group);
-            }
-            entityManager.remove(group);
-        }
+        entityManager.remove(group);
     }
 
     public void updateGroup (UserGroup group) throws KustvaktException {
diff --git a/src/main/java/de/ids_mannheim/korap/service/QueryService.java b/src/main/java/de/ids_mannheim/korap/service/QueryService.java
index c04441f..2c1f9ac 100644
--- a/src/main/java/de/ids_mannheim/korap/service/QueryService.java
+++ b/src/main/java/de/ids_mannheim/korap/service/QueryService.java
@@ -172,7 +172,7 @@
             if (query.getType().equals(ResourceType.PUBLISHED)) {
                 UserGroup group = userGroupDao
                         .retrieveHiddenGroupByQueryName(queryName);
-                userGroupDao.deleteGroup(group.getId(), deletedBy, false);
+                userGroupDao.deleteGroup(group.getId(), deletedBy);
             }
             if (type.equals(QueryType.VIRTUAL_CORPUS)
                     && VirtualCorpusCache.contains(queryName)) {
@@ -234,7 +234,7 @@
                     UserGroup group = userGroupDao
                             .retrieveHiddenGroupByQueryName(queryName);
                     int groupId = group.getId();
-                    userGroupDao.deleteGroup(groupId, username, false);
+                    userGroupDao.deleteGroup(groupId, username);
                     // EM: should the users within the hidden group
                     // receive
                     // notifications?
diff --git a/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java b/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
index 52c79b9..ccb65ad 100644
--- a/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
+++ b/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
@@ -264,17 +264,9 @@
     public void deleteGroup (String groupName, String username)
             throws KustvaktException {
         UserGroup userGroup = retrieveUserGroupByName(groupName);
-        if (userGroup.getStatus() == UserGroupStatus.DELETED) {
-            // EM: should this be "not found" instead?
-            throw new KustvaktException(StatusCodes.GROUP_DELETED,
-                    "Group " + userGroup.getName() + " has been deleted.",
-                    userGroup.getName());
-        }
-        else if (userGroup.getCreatedBy().equals(username)
+        if (userGroup.getCreatedBy().equals(username)
                 || adminDao.isAdmin(username)) {
-            // soft delete
-            userGroupDao.deleteGroup(userGroup.getId(), username,
-                    config.isSoftDeleteGroup());
+            userGroupDao.deleteGroup(userGroup.getId(), username);
         }
         else {
             throw new KustvaktException(StatusCodes.AUTHORIZATION_FAILED,
@@ -393,12 +385,6 @@
         ParameterChecker.checkStringValue(groupMembers, "members");
 
         UserGroup userGroup = retrieveUserGroupByName(groupName);
-        if (userGroup.getStatus() == UserGroupStatus.DELETED) {
-            throw new KustvaktException(StatusCodes.GROUP_DELETED,
-                    "Group " + userGroup.getName() + " has been deleted.",
-                    userGroup.getName());
-        }
-
         if (isUserGroupAdmin(inviter, userGroup) || adminDao.isAdmin(inviter)) {
             for (String memberName : members) {
                 inviteGroupMember(memberName, userGroup, inviter,
@@ -456,12 +442,6 @@
         ParameterChecker.checkStringValue(groupName, "groupName");
 
         UserGroup userGroup = retrieveUserGroupByName(groupName);
-        if (userGroup.getStatus() == UserGroupStatus.DELETED) {
-            throw new KustvaktException(StatusCodes.GROUP_DELETED,
-                    "Group " + userGroup.getName() + " has been deleted.",
-                    userGroup.getName());
-        }
-
         UserGroupMember member = groupMemberDao.retrieveMemberById(username,
                 userGroup.getId());
         GroupMemberStatus status = member.getStatus();
@@ -518,12 +498,7 @@
             String deletedBy) throws KustvaktException {
 
         UserGroup userGroup = retrieveUserGroupByName(groupName);
-        if (userGroup.getStatus() == UserGroupStatus.DELETED) {
-            throw new KustvaktException(StatusCodes.GROUP_DELETED,
-                    "Group " + userGroup.getName() + " has been deleted.",
-                    userGroup.getName());
-        }
-        else if (memberId.equals(userGroup.getCreatedBy())) {
+        if (memberId.equals(userGroup.getCreatedBy())) {
             throw new KustvaktException(StatusCodes.NOT_ALLOWED,
                     "Operation " + "'delete group owner'" + "is not allowed.",
                     "delete group owner");
@@ -589,11 +564,6 @@
         ParameterChecker.checkStringValue(memberUsername, "memberUsername");
 
         UserGroup userGroup = userGroupDao.retrieveGroupByName(groupName, true);
-        UserGroupStatus groupStatus = userGroup.getStatus();
-        if (groupStatus == UserGroupStatus.DELETED) {
-            throw new KustvaktException(StatusCodes.GROUP_DELETED,
-                    "Usergroup has been deleted.");
-        }
 
         if (isUserGroupAdmin(username, userGroup)
                 || adminDao.isAdmin(username)) {
diff --git a/src/test/java/de/ids_mannheim/korap/dao/DaoTestBase.java b/src/test/java/de/ids_mannheim/korap/dao/DaoTestBase.java
index 31cf098..8e32b02 100644
--- a/src/test/java/de/ids_mannheim/korap/dao/DaoTestBase.java
+++ b/src/test/java/de/ids_mannheim/korap/dao/DaoTestBase.java
@@ -47,7 +47,7 @@
     
     protected void deleteUserGroup (int groupId, String username)
             throws KustvaktException {
-        userGroupDao.deleteGroup(groupId, username, false);
+        userGroupDao.deleteGroup(groupId, username);
         KustvaktException exception = assertThrows(KustvaktException.class,
                 () -> {
                     userGroupDao.retrieveGroupById(groupId);