|
21 | 21 |
|
22 | 22 | import java.text.SimpleDateFormat; |
23 | 23 | import java.util.ArrayList; |
| 24 | +import java.util.Arrays; |
24 | 25 | import java.util.Date; |
25 | 26 | import java.util.HashMap; |
26 | 27 | import java.util.List; |
27 | 28 | import java.util.Map; |
28 | 29 | import java.util.TimeZone; |
29 | 30 | import java.util.concurrent.ConcurrentHashMap; |
| 31 | +import java.util.stream.Collectors; |
30 | 32 | import java.util.stream.Stream; |
31 | 33 |
|
32 | 34 | import org.apache.xmlrpc.XmlRpcException; |
@@ -646,17 +648,14 @@ private void importDataV7(RowCollection rows, Object[][] importRows) throws XmlR |
646 | 648 |
|
647 | 649 | HashMap<String, Object> results = command.Load(modelName, targetFieldList, importRows); |
648 | 650 |
|
649 | | - // There was an error. ids is false and not an Object[] |
650 | 651 | if (results.get("ids") instanceof Boolean) { |
651 | | - StringBuilder errorString = new StringBuilder(); |
652 | | - Object[] messages = (Object[]) results.get("messages"); |
653 | | - for (Object mes : messages) { |
654 | | - HashMap<String, Object> messageHash = (HashMap<String, Object>) mes; |
655 | | - errorString.append("Row: " + messageHash.get("record").toString() + " field: " |
656 | | - + messageHash.get("field").toString() + " ERROR: " + messageHash.get("message").toString() |
657 | | - + "\n"); |
658 | | - } |
659 | | - throw new OpeneERPApiException(errorString.toString()); |
| 652 | + // There was an error. ids is false and not an Object[] |
| 653 | + Map<String, Object>[] messages = (Map<String, Object>[]) results.get("messages"); |
| 654 | + String errorString = Arrays.stream(messages) |
| 655 | + .flatMap(m -> m.entrySet().stream()) |
| 656 | + .map(e -> String.join(":", e.getKey(), e.getValue().toString())) |
| 657 | + .collect(Collectors.joining("\n")); |
| 658 | + throw new OpeneERPApiException(errorString); |
660 | 659 | } |
661 | 660 |
|
662 | 661 | // Should be in the same order as it was passed in |
|
0 commit comments