73422: Delete eperson: community feedback

This commit is contained in:
Yana De Pauw
2020-09-28 17:31:00 +02:00
parent f71202c8c3
commit 3b563e4906
8 changed files with 22 additions and 15 deletions

View File

@@ -70,13 +70,14 @@ public class RequestItemMetadataStrategy extends RequestItemSubmitterStrategy {
//First get help desk name and email //First get help desk name and email
email = DSpaceServicesFactory.getInstance() email = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("mail.helpdesk"); .getConfigurationService().getProperty("mail.helpdesk");
name = I18nUtil.getMessage("org.dspace.app.requestitem.helpdeskname", context); name = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("mail.helpdesk.name");
// If help desk mail is null get the mail and name of admin // If help desk mail is null get the mail and name of admin
if (email == null) { if (email == null) {
email = DSpaceServicesFactory.getInstance() email = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("mail.admin"); .getConfigurationService().getProperty("mail.admin");
name = DSpaceServicesFactory.getInstance() name = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("admin.name"); .getConfigurationService().getProperty("mail.admin.name");
} }
author = new RequestItemAuthor(name, email); author = new RequestItemAuthor(name, email);
} }

View File

@@ -253,7 +253,7 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService {
@Override @Override
public void removeAllEPersonPolicies(Context context, EPerson ePerson) throws SQLException, AuthorizeException { public void removeAllEPersonPolicies(Context context, EPerson ePerson) throws SQLException, AuthorizeException {
resourcePolicyDAO.deleteAllEPersonPolicies(context, ePerson); resourcePolicyDAO.deleteByEPerson(context, ePerson);
} }
@Override @Override

View File

@@ -68,7 +68,14 @@ public interface ResourcePolicyDAO extends GenericDAO<ResourcePolicy> {
public void deleteByDsoEPersonPolicies(Context context, DSpaceObject dso, EPerson ePerson) throws SQLException; public void deleteByDsoEPersonPolicies(Context context, DSpaceObject dso, EPerson ePerson) throws SQLException;
public void deleteAllEPersonPolicies(Context context, EPerson ePerson) throws SQLException; /**
* Deletes all policies that belong to an EPerson
*
* @param context DSpace context object
* @param ePerson ePerson whose policies to delete
* @throws SQLException if database error
*/
public void deleteByEPerson(Context context, EPerson ePerson) throws SQLException;
public void deleteByDsoAndTypeNotEqualsTo(Context c, DSpaceObject o, String type) throws SQLException; public void deleteByDsoAndTypeNotEqualsTo(Context c, DSpaceObject o, String type) throws SQLException;
@@ -105,7 +112,7 @@ public interface ResourcePolicyDAO extends GenericDAO<ResourcePolicy> {
* @return total resource policies of the ePerson * @return total resource policies of the ePerson
* @throws SQLException if database error * @throws SQLException if database error
*/ */
public int countByEPerson(Context context, EPerson eperson) throws SQLException; public int countByEPerson(Context context, EPerson ePerson) throws SQLException;
/** /**
* Return a paginated list of policies related to a resourceUuid belong to an ePerson * Return a paginated list of policies related to a resourceUuid belong to an ePerson

View File

@@ -205,7 +205,7 @@ public class ResourcePolicyDAOImpl extends AbstractHibernateDAO<ResourcePolicy>
} }
@Override @Override
public void deleteAllEPersonPolicies(Context context, EPerson ePerson) throws SQLException { public void deleteByEPerson(Context context, EPerson ePerson) throws SQLException {
String queryString = "delete from ResourcePolicy where eperson= :eperson"; String queryString = "delete from ResourcePolicy where eperson= :eperson";
Query query = createQuery(context, queryString); Query query = createQuery(context, queryString);
query.setParameter("eperson", ePerson); query.setParameter("eperson", ePerson);
@@ -266,10 +266,10 @@ public class ResourcePolicyDAOImpl extends AbstractHibernateDAO<ResourcePolicy>
} }
@Override @Override
public int countByEPerson(Context context, EPerson eperson) throws SQLException { public int countByEPerson(Context context, EPerson ePerson) throws SQLException {
Query query = createQuery(context, Query query = createQuery(context,
"SELECT count(*) FROM " + ResourcePolicy.class.getSimpleName() + " WHERE eperson_id = (:epersonUuid) "); "SELECT count(*) FROM " + ResourcePolicy.class.getSimpleName() + " WHERE eperson_id = (:epersonUuid) ");
query.setParameter("epersonUuid", eperson.getID()); query.setParameter("epersonUuid", ePerson.getID());
return count(query); return count(query);
} }

View File

@@ -199,7 +199,6 @@ public class EPersonCLITool {
try { try {
ePersonService.update(context, eperson); ePersonService.update(context, eperson);
context.complete();
System.out.printf("Created EPerson %s\n", eperson.getID().toString()); System.out.printf("Created EPerson %s\n", eperson.getID().toString());
} catch (SQLException ex) { } catch (SQLException ex) {
context.abort(); context.abort();
@@ -264,7 +263,7 @@ public class EPersonCLITool {
try { try {
List<String> tableList = ePersonService.getDeleteConstraints(context, eperson); List<String> tableList = ePersonService.getDeleteConstraints(context, eperson);
if (!tableList.isEmpty()) { if (!tableList.isEmpty()) {
System.out.printf("This EPerson with ID: %s is referring to this tables:%n ", System.out.printf("The EPerson with ID: %s is referenced by the following database tables:%n",
eperson.getID().toString()); eperson.getID().toString());
tableList.forEach((s) -> { tableList.forEach((s) -> {
System.out.println(s); System.out.println(s);
@@ -277,10 +276,9 @@ public class EPersonCLITool {
String s = input.readLine(); String s = input.readLine();
if (s != null && s.trim().toLowerCase().startsWith("y")) { if (s != null && s.trim().toLowerCase().startsWith("y")) {
ePersonService.delete(context, eperson); ePersonService.delete(context, eperson);
context.complete();
System.out.printf("%nDeleted EPerson with ID: %s", eperson.getID().toString()); System.out.printf("%nDeleted EPerson with ID: %s", eperson.getID().toString());
} else { } else {
System.out.printf("%nAbort Deletetion of EPerson with ID: %s %n", eperson.getID().toString()); System.out.printf("%nAbort Deletion of EPerson with ID: %s %n", eperson.getID().toString());
} }
} catch (SQLException | AuthorizeException | IOException ex) { } catch (SQLException | AuthorizeException | IOException ex) {
System.err.println(ex.getMessage()); System.err.println(ex.getMessage());
@@ -387,7 +385,6 @@ public class EPersonCLITool {
if (modified) { if (modified) {
try { try {
ePersonService.update(context, eperson); ePersonService.update(context, eperson);
context.complete();
System.out.printf("Modified EPerson %s\n", eperson.getID().toString()); System.out.printf("Modified EPerson %s\n", eperson.getID().toString());
} catch (SQLException ex) { } catch (SQLException ex) {
context.abort(); context.abort();

View File

@@ -247,7 +247,7 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
throw new AuthorizeException(ex.getMessage()); throw new AuthorizeException(ex.getMessage());
} catch (IOException ex) { } catch (IOException ex) {
log.error("This IOException: " + ex + " occured while deleting Eperson with the ID: " + ePerson.getID()); log.error("This IOException: " + ex + " occured while deleting Eperson with the ID: " + ePerson.getID());
throw new AuthorizeException(new EPersonDeletionException()); throw new AuthorizeException(ex);
} catch (EPersonDeletionException e) { } catch (EPersonDeletionException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }

View File

@@ -217,7 +217,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
throw new IllegalStateException( throw new IllegalStateException(
"Refused to remove sub group " + childGroup "Refused to remove sub group " + childGroup
.getID() + " from workflow group because the group " + groupParent .getID() + " from workflow group because the group " + groupParent
.getID() + " has no other members"); .getID() + " has tasks assigned and no other members");
} }
} }
} }

View File

@@ -121,6 +121,7 @@ feedback.recipient = dspace-help@myu.edu
# General site administration (Webmaster) e-mail # General site administration (Webmaster) e-mail
# System notifications/reports and other sysadmin emails are sent to this address # System notifications/reports and other sysadmin emails are sent to this address
mail.admin = dspace-help@myu.edu mail.admin = dspace-help@myu.edu
mail.admin.name = DSpace Administrator
# Recipient for server errors and alerts (defaults to mail.admin) # Recipient for server errors and alerts (defaults to mail.admin)
alert.recipient = ${mail.admin} alert.recipient = ${mail.admin}
@@ -1965,6 +1966,7 @@ xmlui.search.metadata_export = admin
request.item.type = all request.item.type = all
# Helpdesk E-mail # Helpdesk E-mail
mail.helpdesk = ${mail.admin} mail.helpdesk = ${mail.admin}
mail.helpdesk.name = Help Desk
# Should all Request Copy emails go to the helpdesk instead of the item submitter? # Should all Request Copy emails go to the helpdesk instead of the item submitter?
request.item.helpdesk.override = false request.item.helpdesk.override = false