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
email = DSpaceServicesFactory.getInstance()
.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 (email == null) {
email = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("mail.admin");
name = DSpaceServicesFactory.getInstance()
.getConfigurationService().getProperty("admin.name");
.getConfigurationService().getProperty("mail.admin.name");
}
author = new RequestItemAuthor(name, email);
}

View File

@@ -253,7 +253,7 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService {
@Override
public void removeAllEPersonPolicies(Context context, EPerson ePerson) throws SQLException, AuthorizeException {
resourcePolicyDAO.deleteAllEPersonPolicies(context, ePerson);
resourcePolicyDAO.deleteByEPerson(context, ePerson);
}
@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 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;
@@ -105,7 +112,7 @@ public interface ResourcePolicyDAO extends GenericDAO<ResourcePolicy> {
* @return total resource policies of the ePerson
* @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

View File

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

View File

@@ -199,7 +199,6 @@ public class EPersonCLITool {
try {
ePersonService.update(context, eperson);
context.complete();
System.out.printf("Created EPerson %s\n", eperson.getID().toString());
} catch (SQLException ex) {
context.abort();
@@ -264,7 +263,7 @@ public class EPersonCLITool {
try {
List<String> tableList = ePersonService.getDeleteConstraints(context, eperson);
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());
tableList.forEach((s) -> {
System.out.println(s);
@@ -277,10 +276,9 @@ public class EPersonCLITool {
String s = input.readLine();
if (s != null && s.trim().toLowerCase().startsWith("y")) {
ePersonService.delete(context, eperson);
context.complete();
System.out.printf("%nDeleted EPerson with ID: %s", eperson.getID().toString());
} 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) {
System.err.println(ex.getMessage());
@@ -387,7 +385,6 @@ public class EPersonCLITool {
if (modified) {
try {
ePersonService.update(context, eperson);
context.complete();
System.out.printf("Modified EPerson %s\n", eperson.getID().toString());
} catch (SQLException ex) {
context.abort();

View File

@@ -247,7 +247,7 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
throw new AuthorizeException(ex.getMessage());
} catch (IOException ex) {
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) {
throw new IllegalStateException(e);
}

View File

@@ -217,7 +217,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
throw new IllegalStateException(
"Refused to remove sub group " + childGroup
.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
# System notifications/reports and other sysadmin emails are sent to this address
mail.admin = dspace-help@myu.edu
mail.admin.name = DSpace Administrator
# Recipient for server errors and alerts (defaults to mail.admin)
alert.recipient = ${mail.admin}
@@ -1965,6 +1966,7 @@ xmlui.search.metadata_export = admin
request.item.type = all
# Helpdesk E-mail
mail.helpdesk = ${mail.admin}
mail.helpdesk.name = Help Desk
# Should all Request Copy emails go to the helpdesk instead of the item submitter?
request.item.helpdesk.override = false