Exemplo n.º 1
0
 /**
  * @param clazz
  * @param dataFile
  * @return
  * @throws Exception
  */
 private <T> T getData(Class<T> clazz, File dataFile) throws Exception {
   try {
     return codec.dec().from(dataFile).get(clazz);
   } catch (Exception e) {
     // e.printStackTrace();
     // System.out.println("Cannot read data file "+dataFile+": " +
     // IO.collect(dataFile));
     return null;
   }
 }
Exemplo n.º 2
0
  public ArtifactData get(byte[] sha) throws Exception {
    String name = Hex.toHexString(sha);
    File data = IO.getFile(repoDir, name + ".json");
    reporter.trace("artifact data file %s", data);
    if (data.isFile()) { // Bin + metadata
      ArtifactData artifact = codec.dec().from(data).get(ArtifactData.class);
      artifact.file = IO.getFile(repoDir, name).getAbsolutePath();
      return artifact;
    }
    File bin = IO.getFile(repoDir, name);
    if (bin.exists()) { // Only bin
      ArtifactData artifact = new ArtifactData();
      artifact.file = bin.getAbsolutePath();
      artifact.sha = sha;
      return artifact;
    }

    return null;
  }