Showing
1 changed file
with
9 additions
and
3 deletions
... | ... | @@ -55,7 +55,7 @@ public class DatabaseHelper { |
55 | 55 | |
56 | 56 | public static void upgradeTo40_assignDashboards(Path dashboardsDump, DashboardService dashboardService, boolean sql) throws Exception { |
57 | 57 | String[] columns = new String[]{ID, TENANT_ID, CUSTOMER_ID, TITLE, SEARCH_TEXT, ASSIGNED_CUSTOMERS, CONFIGURATION}; |
58 | - try (CSVParser csvParser = new CSVParser(Files.newBufferedReader(dashboardsDump), CSV_DUMP_FORMAT.withHeader(columns))) { | |
58 | + try (CSVParser csvParser = new CSVParser(Files.newBufferedReader(dashboardsDump), CSV_DUMP_FORMAT.withFirstRecordAsHeader())) { | |
59 | 59 | csvParser.forEach(record -> { |
60 | 60 | String customerIdString = record.get(CUSTOMER_ID); |
61 | 61 | String assignedCustomersString = record.get(ASSIGNED_CUSTOMERS); |
... | ... | @@ -66,14 +66,20 @@ public class DatabaseHelper { |
66 | 66 | JsonNode assignedCustomersJson = objectMapper.readTree(assignedCustomersString); |
67 | 67 | Map<String,String> assignedCustomers = objectMapper.treeToValue(assignedCustomersJson, HashMap.class); |
68 | 68 | assignedCustomers.forEach((strCustomerId, title) -> { |
69 | - customerIds.add(new CustomerId(UUID.fromString(strCustomerId))); | |
69 | + CustomerId customerId = new CustomerId(UUID.fromString(strCustomerId)); | |
70 | + if (!customerId.isNullUid()) { | |
71 | + customerIds.add(new CustomerId(UUID.fromString(strCustomerId))); | |
72 | + } | |
70 | 73 | }); |
71 | 74 | } catch (IOException e) { |
72 | 75 | log.error("Unable to parse assigned customers field", e); |
73 | 76 | } |
74 | 77 | } |
75 | 78 | if (!StringUtils.isEmpty(customerIdString)) { |
76 | - customerIds.add(new CustomerId(toUUID(customerIdString, sql))); | |
79 | + CustomerId customerId = new CustomerId(toUUID(customerIdString, sql)); | |
80 | + if (!customerId.isNullUid()) { | |
81 | + customerIds.add(new CustomerId(toUUID(customerIdString, sql))); | |
82 | + } | |
77 | 83 | } |
78 | 84 | for (CustomerId customerId : customerIds) { |
79 | 85 | dashboardService.assignDashboardToCustomer(dashboardId, customerId); | ... | ... |