+ * NOTE: when run in workflow, curation tasks run with
+ * authorization disabled.
+ *
* @see CurationTaskConfig
* @author mwood
*/
@Service
public class XmlWorkflowCuratorServiceImpl
implements XmlWorkflowCuratorService {
- private static final Logger LOG
- = org.apache.logging.log4j.LogManager.getLogger();
+ private static final Logger LOG = LogManager.getLogger();
@Autowired(required = true)
protected XmlWorkflowFactory workflowFactory;
@@ -97,7 +103,18 @@ public class XmlWorkflowCuratorServiceImpl
throws AuthorizeException, IOException, SQLException {
Curator curator = new Curator();
curator.setReporter(reporter);
- return curate(curator, c, wfi);
+ c.turnOffAuthorisationSystem();
+ boolean wasAnonymous = false;
+ if (null == c.getCurrentUser()) { // We need someone to email
+ wasAnonymous = true;
+ c.setCurrentUser(ePersonService.getSystemEPerson(c));
+ }
+ boolean failedP = curate(curator, c, wfi);
+ if (wasAnonymous) {
+ c.setCurrentUser(null);
+ }
+ c.restoreAuthSystemState();
+ return failedP;
}
@Override
@@ -123,40 +140,47 @@ public class XmlWorkflowCuratorServiceImpl
item.setOwningCollection(wfi.getCollection());
for (Task task : step.tasks) {
curator.addTask(task.name);
- curator.curate(item);
- int status = curator.getStatus(task.name);
- String result = curator.getResult(task.name);
- String action = "none";
- switch (status) {
- case Curator.CURATE_FAIL:
- // task failed - notify any contacts the task has assigned
- if (task.powers.contains("reject")) {
- action = "reject";
- }
- notifyContacts(c, wfi, task, "fail", action, result);
- // if task so empowered, reject submission and terminate
- if ("reject".equals(action)) {
- workflowService.sendWorkflowItemBackSubmission(c, wfi,
- c.getCurrentUser(), null,
- task.name + ": " + result);
- return false;
- }
- break;
- case Curator.CURATE_SUCCESS:
- if (task.powers.contains("approve")) {
- action = "approve";
- }
- notifyContacts(c, wfi, task, "success", action, result);
- if ("approve".equals(action)) {
- // cease further task processing and advance submission
- return true;
- }
- break;
- case Curator.CURATE_ERROR:
- notifyContacts(c, wfi, task, "error", action, result);
- break;
- default:
- break;
+ // Check whether the task is configured to be queued rather than automatically run
+ if (StringUtils.isNotEmpty(step.queue)) {
+ // queue attribute has been set in the FlowStep configuration: add task to configured queue
+ curator.queue(c, item.getID().toString(), step.queue);
+ } else {
+ // Task is configured to be run automatically
+ curator.curate(c, item);
+ int status = curator.getStatus(task.name);
+ String result = curator.getResult(task.name);
+ String action = "none";
+ switch (status) {
+ case Curator.CURATE_FAIL:
+ // task failed - notify any contacts the task has assigned
+ if (task.powers.contains("reject")) {
+ action = "reject";
+ }
+ notifyContacts(c, wfi, task, "fail", action, result);
+ // if task so empowered, reject submission and terminate
+ if ("reject".equals(action)) {
+ workflowService.sendWorkflowItemBackSubmission(c, wfi,
+ c.getCurrentUser(), null,
+ task.name + ": " + result);
+ return false;
+ }
+ break;
+ case Curator.CURATE_SUCCESS:
+ if (task.powers.contains("approve")) {
+ action = "approve";
+ }
+ notifyContacts(c, wfi, task, "success", action, result);
+ if ("approve".equals(action)) {
+ // cease further task processing and advance submission
+ return true;
+ }
+ break;
+ case Curator.CURATE_ERROR:
+ notifyContacts(c, wfi, task, "error", action, result);
+ break;
+ default:
+ break;
+ }
}
curator.clear();
}
@@ -223,8 +247,12 @@ public class XmlWorkflowCuratorServiceImpl
String status, String action, String message)
throws AuthorizeException, IOException, SQLException {
List
+ * WARNING: This method may have bad performance for Groups with large numbers of EPerson members.
+ * Therefore, only use this when you need to access every EPerson member. Instead, consider using
+ * EPersonService.findByGroups() for a paginated list of EPersons.
*
* @return list of EPersons
*/
@@ -143,9 +147,13 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport {
}
/**
- * Return Group members of a Group.
+ * Return Group members (i.e. direct subgroups) of a Group.
+ *
+ * WARNING: This method may have bad performance for Groups with large numbers of Subgroups.
+ * Therefore, only use this when you need to access every Subgroup. Instead, consider using
+ * GroupService.findByParent() for a paginated list of Subgroups.
*
- * @return list of groups
+ * @return list of subgroups
*/
public List