73783: Delete eperson: community feedback part 2

This commit is contained in:
Yana De Pauw
2020-10-01 10:48:46 +02:00
parent 3b563e4906
commit 9b169afd35
7 changed files with 99 additions and 6 deletions

View File

@@ -74,7 +74,8 @@ public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
return new RequestItemAuthor(helpdeskEPerson);
} else {
String helpdeskName = I18nUtil.getMessage(
"org.dspace.app.requestitem.helpdeskname", context);
"org.dspace.app.requestitem.RequestItemHelpdeskStrategy.helpdeskname",
context);
return new RequestItemAuthor(helpdeskName, helpDeskEmail);
}
}

View File

@@ -39,6 +39,14 @@ public interface ResourcePolicyService extends DSpaceCRUDService<ResourcePolicy>
public List<ResourcePolicy> find(Context context, Group group) throws SQLException;
/**
* Retrieve a list of ResourcePolicies by EPerson
*
* @param c context
* @param ePerson the EPerson for which to look up the resource policies
* @return a list of ResourcePolicies for the provided EPerson
* @throws SQLException if there's a database problem
*/
public List<ResourcePolicy> find(Context c, EPerson ePerson) throws SQLException;
public List<ResourcePolicy> find(Context c, EPerson e, List<Group> groups, int action, int type_id)
@@ -74,6 +82,14 @@ public interface ResourcePolicyService extends DSpaceCRUDService<ResourcePolicy>
public void removeDsoEPersonPolicies(Context context, DSpaceObject dso, EPerson ePerson)
throws SQLException, AuthorizeException;
/**
* Removes all ResourcePolicies related to an EPerson
*
* @param context context
* @param ePerson the EPerson for which the ResourcePolicies will be deleted
* @throws SQLException if there's a database problem
* @throws AuthorizeException when the current user is not authorized
*/
public void removeAllEPersonPolicies(Context context, EPerson ePerson) throws SQLException, AuthorizeException;
public void removeGroupPolicies(Context c, Group group) throws SQLException;

View File

@@ -47,6 +47,16 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
public Iterator<Item> findBySubmitter(Context context, EPerson eperson) throws SQLException;
/**
* Find all the items by a given submitter. The order is
* indeterminate. All items are included.
*
* @param context DSpace context object
* @param eperson the submitter
* @param retrieveAllItems flag to determine if only archive should be returned
* @return an iterator over the items submitted by eperson
* @throws SQLException if database error
*/
public Iterator<Item> findBySubmitter(Context context, EPerson eperson, boolean retrieveAllItems)
throws SQLException;

View File

@@ -111,10 +111,10 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
@Override
public Iterator<Item> findBySubmitter(Context context, EPerson eperson, boolean retrieveAllItems)
throws SQLException {
Query query = createQuery(context, "FROM Item WHERE submitter= :submitter");
if (!retrieveAllItems) {
return findBySubmitter(context, eperson);
}
Query query = createQuery(context, "FROM Item WHERE submitter= :submitter");
query.setParameter("submitter", eperson);
return iterate(query);
}

View File

@@ -119,7 +119,9 @@ public interface ItemService
*
* @param context DSpace context object
* @param eperson the submitter
* @param retrieveAllItems flag to determine if only archive should be returned
* @param retrieveAllItems flag to determine if all items should be returned or only archived items.
* If true, all items (regardless of status) are returned.
* If false, only archived items will be returned.
* @return an iterator over the items submitted by eperson
* @throws SQLException if database error
*/

View File

@@ -244,7 +244,7 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
} catch (AuthorizeException ex) {
log.error("This AuthorizeException: " + ex + " occured while deleting Eperson with the ID: " +
ePerson.getID());
throw new AuthorizeException(ex.getMessage());
throw new AuthorizeException(ex);
} catch (IOException ex) {
log.error("This IOException: " + ex + " occured while deleting Eperson with the ID: " + ePerson.getID());
throw new AuthorizeException(ex);
@@ -284,8 +284,8 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
List<EPerson> ePeople = groupService.allMembers(context, group);
if (ePeople.size() == 1 && ePeople.contains(ePerson)) {
throw new IllegalStateException(
"Refused to delete user " + ePerson.getID() + " because it is part of the group " + group
.getID());
"Refused to delete user " + ePerson.getID() + " because it the only member of the workflow group"
+ group.getID() + ". Delete the tasks and group first if you want to remove this user.");
}
}
// check for presence of eperson in tables that

View File

@@ -119,6 +119,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after user has been removed from the workflow
* group and the task has been passed, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -187,6 +191,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after user has been removed from the workflow
* group and the task has been passed, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -252,6 +260,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after user has been removed from the workflow
* group and the task has been passed, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -314,6 +326,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after user has been removed from the workflow
* group and the task has been passed, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -381,6 +397,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after user has been removed from the workflow
* group and the task has been passed, the EPerson can be removed.
*
* This test has the following setup:
* - Collection A - Step 1: user B
* - Collection A - Step 2: user C
@@ -456,6 +476,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after user has been removed from the workflow
* group and the task has been passed, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -517,6 +541,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after user has been removed from the workflow
* group and the task has been passed, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -583,6 +611,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after another user has been added to the workflow
* group, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -654,6 +686,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after another user has been added to the workflow
* group, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -720,6 +756,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after another user has been added to the workflow
* group, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -785,6 +825,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after another user has been added to the workflow
* group, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -851,6 +895,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after another user has been added to the workflow
* group, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -916,6 +964,10 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson cannot be removed if they are the only member of a Workflow Group that has
* tasks currently assigned to it. This test also verifies that after another user has been added to the workflow
* group, the EPerson can be removed.
*
* This test has the following setup:
* - Step 1: user B
* - Step 2: user C
@@ -984,6 +1036,8 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson can be removed if there is another user is present in the Workflow Group.
*
* This test has the following setup:
* - Step 1: user B and D
* - Step 2: user C and D
@@ -1042,6 +1096,8 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson can be removed if there is another user is present in the Workflow Group.
*
* This test has the following setup:
* - Step 1: user B and D
* - Step 2: user C and D
@@ -1102,6 +1158,8 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson can be removed if there is another user is present in the Workflow Group.
*
* This test has the following setup:
* - Step 1: user B and D
* - Step 2: user C and D
@@ -1162,6 +1220,8 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson can be removed if there is another user is present in the Workflow Group.
*
* This test has the following setup:
* - Step 1: user B and D
* - Step 2: user C and D
@@ -1223,6 +1283,8 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson can be removed if there is another user is present in the Workflow Group.
*
* This test has the following setup:
* - Step 1: user B and D
* - Step 2: user C and D
@@ -1285,6 +1347,8 @@ public class EPersonInWorkflowTest extends AbstractIntegrationTestWithDatabase {
}
/**
* This test verifies that an EPerson can be removed if there is another user is present in the Workflow Group.
*
* This test has the following setup:
* - Step 1: user B and D
* - Step 2: user C and D