net.i2p.router.news

## Class PersistNews

- java.lang.Object
- - net.i2p.router.news.PersistNews

-     class PersistNews
      extends Object

  Handles persistent storage and retrieval of news entries to/from disk.

  Manages individual news entries stored in separate compressed XML files named with UUID-based file names. Provides atomic write operations and compressed storage for efficient disk usage and data integrity.

  Supports loading of news collections with proper sorting, validation, and error handling. Includes utilities for file naming based on content hashes and secure file operations.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PersistNews()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `delete(I2PAppContext ctx, NewsEntry entry)` Unused for now, as we don't have any way to remember it's deleted.
    `static List<NewsEntry>` | `load(I2PAppContext ctx)` This does not check for any missing values.
    `static boolean` | `store(I2PAppContext ctx, List<Node> entries)` Store each entry.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PersistNews

          PersistNews()

  - ### Method Detail

    - #### delete

          public static boolean delete(I2PAppContext ctx,
                                       NewsEntry entry)

      Unused for now, as we don't have any way to remember it's deleted.
      Returns:
        success

    - #### load

          public static List<NewsEntry> load(I2PAppContext ctx)

      This does not check for any missing values. Any fields in any NewsEntry may be null. Content is not sanitized by NewsXMLParser here, do that before storing.
      Returns:
        non-null, sorted by updated date, newest first

    - #### store

          public static boolean store(I2PAppContext ctx,
                                      List<Node> entries)

      Store each entry. Old entries are always overwritten, as they may change even without the updated date changing.
      Parameters:
        `entries` - each one should be "entry" at the root
      Returns:
        true if any new entry was written (not if changed)