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 static void fromJSON(Reader r, ConfigurationAdmin admin) throws Exception {

    Decoder decoder = codec.dec().from(r);
    Protocol p = decoder.get(Protocol.class);
    for (int i = 0; i < p.size; i++) {
      Export e = decoder.get(Export.class);
      Configuration c;
      if (e.factoryPid != null) {
        c = admin.createFactoryConfiguration(e.factoryPid, "?*");
      } else {
        c = admin.getConfiguration(e.pid, "?*");
      }

      Dictionary<String, Object> d = getDictionary(e.types, e.values);
      c.update(d);
    }
  }
Exemplo n.º 3
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;
  }