Make workflow curation tasks actually work.

When curation runs, there was no "current user" and no claimed task,
so the code broke when trying to find people to notify about curation
failures.
This commit is contained in:
Mark H. Wood
2023-08-01 17:13:07 -04:00
parent 7f9ec2eb1e
commit a76af35a0c
3 changed files with 52 additions and 7 deletions

View File

@@ -47,6 +47,7 @@ import org.dspace.eperson.service.GroupService;
import org.dspace.eperson.service.SubscribeService;
import org.dspace.event.Event;
import org.dspace.orcid.service.OrcidTokenService;
import org.dspace.services.ConfigurationService;
import org.dspace.util.UUIDUtils;
import org.dspace.versioning.Version;
import org.dspace.versioning.VersionHistory;
@@ -101,6 +102,8 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
protected VersionDAO versionDAO;
@Autowired(required = true)
protected ClaimedTaskService claimedTaskService;
@Autowired(required = true)
protected ConfigurationService configurationService;
@Autowired
protected OrcidTokenService orcidTokenService;
@@ -113,6 +116,21 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl<EPerson> impleme
return ePersonDAO.findByID(context, EPerson.class, id);
}
@Override
public EPerson findAnAdministrator(Context c)
throws SQLException {
List<EPerson> contacts = groupService.findByName(c, Group.ADMIN).getMembers();
EPerson currentUser;
if (contacts.isEmpty()) {
log.warn("Administrators group is empty");
currentUser = findByEmail(c, configurationService.getProperty("mail.admin"));
// Null if no such EPerson
} else {
currentUser = contacts.get(0);
}
return currentUser;
}
@Override
public EPerson findByIdOrLegacyId(Context context, String id) throws SQLException {
if (StringUtils.isNumeric(id)) {