|
8 | 8 | package org.roda.core.transaction; |
9 | 9 |
|
10 | 10 | import java.nio.file.Path; |
| 11 | +import java.util.Arrays; |
11 | 12 | import java.util.Date; |
12 | 13 | import java.util.List; |
13 | 14 | import java.util.Map; |
| 15 | +import java.util.Set; |
14 | 16 | import java.util.UUID; |
15 | 17 | import java.util.concurrent.ConcurrentHashMap; |
| 18 | +import java.util.stream.Collectors; |
16 | 19 |
|
17 | 20 | import org.roda.core.config.ConfigurationManager; |
18 | 21 | import org.roda.core.data.common.RodaConstants; |
@@ -126,11 +129,24 @@ private void processPluginExecutionResult(Plugin<IsRODAObject> plugin, UUID tran |
126 | 129 | List<Report> nonFailedReports = relatedReports.stream() |
127 | 130 | .filter(report -> !PluginState.FAILURE.equals(report.getPluginState())).toList(); |
128 | 131 |
|
129 | | - if (!failedReports.isEmpty()) { |
130 | | - rollbackTransaction(transactionId); |
131 | | - RODATransactionManagerUtils.createTransactionFailureReports(failedReports, nonFailedReports, transactionId, |
132 | | - initDate, mainModelService); |
133 | | - } else { |
| 132 | + String noRollback = plugin.getParameterValues() |
| 133 | + .getOrDefault(RodaConstants.PLUGIN_PARAM_SKIP_ROLLBACK_ON_VALIDATION_FAILURE, ""); |
| 134 | + Set<String> noRollbackPlugins = Arrays.stream(noRollback.split(",")).map(String::trim).filter(s -> !s.isEmpty()) |
| 135 | + .collect(Collectors.toSet()); |
| 136 | + boolean shouldRollback = false; |
| 137 | + for (Report failedReport : failedReports) { |
| 138 | + for (Report nestedReport : failedReport.getReports()) { |
| 139 | + if (nestedReport.getPluginState().equals(PluginState.FAILURE) |
| 140 | + && !noRollbackPlugins.contains(nestedReport.getPlugin())) { |
| 141 | + rollbackTransaction(transactionId); |
| 142 | + RODATransactionManagerUtils.createTransactionFailureReports(failedReports, nonFailedReports, transactionId, |
| 143 | + initDate, mainModelService); |
| 144 | + shouldRollback = true; |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + if (!shouldRollback) { |
134 | 150 | endTransaction(transactionId); |
135 | 151 | RODATransactionManagerUtils.createTransactionSuccessReports(relatedReports, transactionId, initDate, |
136 | 152 | mainModelService); |
|
0 commit comments