java.lang.Object
org.elasticsearch.xpack.security.support.SecurityFiles

public class SecurityFiles extends Object
  • Method Details

    • writeFileAtomically

      public static <K, V> void writeFileAtomically(Path path, Map<K,V> map, Function<Map.Entry<K,V>,String> transform)
      Atomically writes to the specified file a line per entry in the specified map using the specified transform to convert each entry to a line. The writing is done atomically in the following sense: first the lines are written to a temporary file and if the writing succeeds then the temporary file is moved to the specified path, replacing the file if it exists. If a failure occurs, any existing file is preserved, and the temporary file is cleaned up.
      Type Parameters:
      K - the key type of the map entries
      V - the value type of the map entries
      Parameters:
      path - the path
      map - the map whose entries to transform into lines
      transform - the transform to convert each map entry to a line