private Iterable<Object> saveAndDeleteFiles(
      JSONArray oldFiles, JSONArray newFiles, String entityPath) {
    Iterable<Object> toDelete =
        Sets.difference(Sets.newHashSet(oldFiles), Sets.newHashSet(newFiles));
    Iterable<Object> toSave = Sets.difference(Sets.newHashSet(newFiles), Sets.newHashSet(oldFiles));

    toDelete.forEach(file -> fileStoreService.delete(((LinkedHashMap) file).get("id").toString()));
    saveFiles(toSave, entityPath);
    return toDelete;
  }
  public void deleteFiles(SchemaFormContentAware entity) {
    Object json = defaultConfiguration().jsonProvider().parse(entity.getContent());
    DocumentContext context =
        JsonPath.using(defaultConfiguration().addOptions(Option.AS_PATH_LIST)).parse(json);
    DocumentContext reader =
        new JsonReader(defaultConfiguration().addOptions(Option.REQUIRE_PROPERTIES)).parse(json);

    try {
      ((JSONArray) context.read("$..obibaFiles"))
          .stream()
          .map(p -> (JSONArray) reader.read(p.toString()))
          .flatMap(Collection::stream)
          .forEach(file -> fileStoreService.delete(((LinkedHashMap) file).get("id").toString()));
    } catch (PathNotFoundException e) {
    }
  }