Class CaldavServerStorage

java.lang.Object
org.exoplatform.caldav.storage.CaldavServerStorage

@Component public class CaldavServerStorage extends Object
Maps CalDAV server registrations between their JPA entity and the credential-free CaldavServer DTO. No business logic lives here: the provider-name derivation is mechanical (the seed name is given by the service, every other row derives its name from its own id) and the choices — who may write, when to seed — belong to the service.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Long
    Fallback cache-busting version for rows whose image has no readable modification date.
    static final String
    FileService namespace the uploaded server images are stored under.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Counts the registrations — what the seeding decision reads: the seed row is only ever written into an empty registry, so an administrator's edits are never overwritten by a restart.
    org.exoplatform.caldav.model.CaldavServer
    createSeedServer(org.exoplatform.caldav.model.CaldavServer server, String providerName)
    Creates the seed registration under the fixed legacy provider name — the one row whose provider the kernel plugin already registers, so the accounts connected before the registry existed keep resolving through it.
    org.exoplatform.caldav.model.CaldavServer
    createServer(org.exoplatform.caldav.model.CaldavServer server, String providerNamePrefix)
    Creates a registration whose provider name derives from its own row id (<providerNamePrefix>.<id>).
    boolean
    deleteServer(long serverId)
    Deletes a registration row and, with it, its uploaded image — the file has no other referrer, so keeping it would only leak storage.
    org.exoplatform.caldav.model.CaldavServer
    getServerById(long id)
    Reads one registration by its technical identifier.
    org.exoplatform.caldav.model.CaldavServer
    Reads one registration by the agenda remote provider it is bridged to.
    List<org.exoplatform.caldav.model.CaldavServer>
    Reads every registration, seed first (it holds the lowest id by construction).
    org.exoplatform.caldav.model.CaldavServer
    updateServer(org.exoplatform.caldav.model.CaldavServer server)
    Updates the user-editable fields of a registration: name, description, URL and activation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NAME_SPACE

      public static final String NAME_SPACE
      FileService namespace the uploaded server images are stored under.
      See Also:
    • DEFAULT_LAST_MODIFIED

      public static final Long DEFAULT_LAST_MODIFIED
      Fallback cache-busting version for rows whose image has no readable modification date.
  • Constructor Details

    • CaldavServerStorage

      public CaldavServerStorage()
  • Method Details

    • getServers

      public List<org.exoplatform.caldav.model.CaldavServer> getServers()
      Reads every registration, seed first (it holds the lowest id by construction).
      Returns:
      all registrations, ordered by id
    • getServerById

      public org.exoplatform.caldav.model.CaldavServer getServerById(long id)
      Reads one registration by its technical identifier.
      Parameters:
      id - technical identifier of the registration
      Returns:
      the registration, or null when the row does not exist
    • getServerByProviderName

      public org.exoplatform.caldav.model.CaldavServer getServerByProviderName(String providerName)
      Reads one registration by the agenda remote provider it is bridged to.
      Parameters:
      providerName - name of the agenda remote provider
      Returns:
      the registration, or null when none carries that name
    • countServers

      public long countServers()
      Counts the registrations — what the seeding decision reads: the seed row is only ever written into an empty registry, so an administrator's edits are never overwritten by a restart.
      Returns:
      number of registration rows
    • createServer

      @Transactional public org.exoplatform.caldav.model.CaldavServer createServer(org.exoplatform.caldav.model.CaldavServer server, String providerNamePrefix)
      Creates a registration whose provider name derives from its own row id (<providerNamePrefix>.<id>). Two steps in one transaction — insert, then name the row after the id the insert produced — because the column is NOT NULL and the id does not exist before the insert. The transaction keeps the intermediate placeholder name unobservable.
      Parameters:
      server - registration to create (provider name ignored)
      providerNamePrefix - prefix the provider name is derived from
      Returns:
      the created registration, carrying its id and provider name
    • createSeedServer

      @Transactional public org.exoplatform.caldav.model.CaldavServer createSeedServer(org.exoplatform.caldav.model.CaldavServer server, String providerName)
      Creates the seed registration under the fixed legacy provider name — the one row whose provider the kernel plugin already registers, so the accounts connected before the registry existed keep resolving through it.
      Parameters:
      server - registration to create
      providerName - fixed provider name of the seed
      Returns:
      the created registration
    • updateServer

      @Transactional public org.exoplatform.caldav.model.CaldavServer updateServer(org.exoplatform.caldav.model.CaldavServer server)
      Updates the user-editable fields of a registration: name, description, URL and activation. The provider name never changes — it is the join key user settings and agenda rows hang from.
      Parameters:
      server - registration carrying the id to update and the new values
      Returns:
      the updated registration, or null when the row does not exist
    • deleteServer

      @Transactional public boolean deleteServer(long serverId)
      Deletes a registration row and, with it, its uploaded image — the file has no other referrer, so keeping it would only leak storage.
      Parameters:
      serverId - technical identifier of the registration
      Returns:
      true when a row was deleted, false when none carried that id