Directory directory(JSONObject json) throws IOException {
   if (json.has("location")) {
     return new Directory(new File(json.getString("location")));
   } else {
     return Directory.createNew(importer.getUploadRoot());
   }
 }
  Mosaic mosaic(JSONObject json) throws IOException {
    Mosaic m =
        new Mosaic(
            json.has("location")
                ? new File(json.getString("location"))
                : Directory.createNew(importer.getUploadRoot()).getFile());
    if (json.has("name")) {
      m.setName(json.getString("name"));
    }
    if (json.containsKey("time")) {
      JSONObject time = json.getJSONObject("time");
      if (!time.containsKey("mode")) {
        throw new IllegalArgumentException(
            "time object must specific mode property as " + "one of " + TimeMode.values());
      }

      m.setTimeMode(TimeMode.valueOf(time.getString("mode").toUpperCase()));
      m.getTimeHandler().init(time);
    }
    return m;
  }