Exemplo n.º 1
0
  private void exportDistributorVersions(File baseDir) throws IOException {
    List<DistributorVersion> versions = distVerCurator.findAll();
    if (versions == null || versions.isEmpty()) {
      return;
    }

    File distVerDir = new File(baseDir.getCanonicalPath(), "distributor_version");
    distVerDir.mkdir();

    FileWriter writer = null;
    for (DistributorVersion dv : versions) {
      if (log.isDebugEnabled()) {
        log.debug("Exporting Distributor Version" + dv.getName());
      }
      try {
        File file = new File(distVerDir.getCanonicalPath(), dv.getName() + ".json");
        writer = new FileWriter(file);
        distVerExporter.export(mapper, writer, dv);
      } finally {
        if (writer != null) {
          writer.close();
        }
      }
    }
  }
Exemplo n.º 2
0
 public void verify(ZipInputStream zis, byte[] buf) throws IOException {
   OutputStream os = new FileOutputStream("/tmp/" + filename);
   int n;
   while ((n = zis.read(buf, 0, 1024)) > -1) {
     os.write(buf, 0, n);
   }
   os.flush();
   os.close();
   ObjectMapper om =
       SyncUtils.getObjectMapper(
           new MapConfiguration(
               new HashMap<String, String>() {
                 {
                   put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES, "false");
                 }
               }));
   DistributorVersion dv =
       om.readValue(new FileInputStream("/tmp/" + filename), DistributorVersion.class);
   assertNotNull(dv);
   assertEquals("test-dist-ver", dv.getName());
   assertEquals(3, dv.getCapabilities().size());
 }