Commit 7645e6f26ecc8e341194fc155c05026970abdcaa

Authored by Igor Kulikov
1 parent 99444395

Fix Dashboards dump parsing

@@ -55,7 +55,7 @@ public class DatabaseHelper { @@ -55,7 +55,7 @@ public class DatabaseHelper {
55 55
56 public static void upgradeTo40_assignDashboards(Path dashboardsDump, DashboardService dashboardService, boolean sql) throws Exception { 56 public static void upgradeTo40_assignDashboards(Path dashboardsDump, DashboardService dashboardService, boolean sql) throws Exception {
57 String[] columns = new String[]{ID, TENANT_ID, CUSTOMER_ID, TITLE, SEARCH_TEXT, ASSIGNED_CUSTOMERS, CONFIGURATION}; 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 csvParser.forEach(record -> { 59 csvParser.forEach(record -> {
60 String customerIdString = record.get(CUSTOMER_ID); 60 String customerIdString = record.get(CUSTOMER_ID);
61 String assignedCustomersString = record.get(ASSIGNED_CUSTOMERS); 61 String assignedCustomersString = record.get(ASSIGNED_CUSTOMERS);
@@ -66,14 +66,20 @@ public class DatabaseHelper { @@ -66,14 +66,20 @@ public class DatabaseHelper {
66 JsonNode assignedCustomersJson = objectMapper.readTree(assignedCustomersString); 66 JsonNode assignedCustomersJson = objectMapper.readTree(assignedCustomersString);
67 Map<String,String> assignedCustomers = objectMapper.treeToValue(assignedCustomersJson, HashMap.class); 67 Map<String,String> assignedCustomers = objectMapper.treeToValue(assignedCustomersJson, HashMap.class);
68 assignedCustomers.forEach((strCustomerId, title) -> { 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 } catch (IOException e) { 74 } catch (IOException e) {
72 log.error("Unable to parse assigned customers field", e); 75 log.error("Unable to parse assigned customers field", e);
73 } 76 }
74 } 77 }
75 if (!StringUtils.isEmpty(customerIdString)) { 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 for (CustomerId customerId : customerIds) { 84 for (CustomerId customerId : customerIds) {
79 dashboardService.assignDashboardToCustomer(dashboardId, customerId); 85 dashboardService.assignDashboardToCustomer(dashboardId, customerId);