@Test public void testPreLoad() { File landingZone = Files.createTempDir(); try { assertTrue(tenantProcessor.preLoad(landingZone.getAbsolutePath(), Arrays.asList("small"))); assertTrue(landingZone.list(new WildcardFileFilter("preload-*.zip")).length == 1); } finally { landingZone.delete(); } }
boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; }
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; } }
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; }  }
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; }  @Override void process(Exchange exchange); }
TenantProcessor implements Processor { boolean preLoad(String landingZone, List<String> dataSets) { File landingZoneDir = new File(landingZone); if (!landingZoneDir.exists()) { try { FileUtils.forceMkdir(landingZoneDir); } catch (IOException e) { LOG.error("TenantProcessor: Failed to create landing zone: {} with absolute path {}", landingZone, landingZoneDir.getAbsolutePath()); return false; } } if (landingZoneDir.exists() && landingZoneDir.isDirectory()) { boolean result = true; for (String dataSet : dataSets) { List<String> fileNames = getDataSetLookup().get(dataSet); if (fileNames != null) { for (String fileName : fileNames) { URL fileLocation = Thread.currentThread().getContextClassLoader().getResource(fileName); try { InputStream sampleFile = fileLocation == null ? new FileInputStream(fileName) : fileLocation.openStream(); result &= sendToLandingZone(landingZoneDir, sampleFile); } catch (FileNotFoundException e) { LOG.error("sample data set {} doesn't exists", fileName); result = false; } catch (IOException e) { LOG.error("error loading sample data set", e); } } } else { result = false; } } return result; } return false; }  @Override void process(Exchange exchange); static final String TENANT_POLL_HEADER; static final String TENANT_POLL_SUCCESS; static final String TENANT_POLL_FAILURE; }