Interface VersionService<E extends VersionedModel<V>,V extends VersionModel<E>>


public interface VersionService<E extends VersionedModel<V>,V extends VersionModel<E>>
Provides a way to view versions, create new drafts, publish drafts, and roll back versions of versioned models.
Author:
Preston Crary
See Also:
  • Method Details

    • checkout

      E checkout(E publishedVersionedModel, int version) throws PortalException
      Checks out the previous version of the versioned model and saves it as a draft. Any VersionServiceListener that has been registered is also notified. An IllegalArgumentException is thrown if the versioned model already has a draft.
      Parameters:
      publishedVersionedModel - the published versioned model
      version - the version
      Returns:
      the draft VersionModel being checked out
      Throws:
      PortalException - if the version does not exist
    • create

      E create()
      Creates a new draft VersionedModel. The versioned model is not added to the database.
      Returns:
      the new draft versioned model
    • delete

      E delete(E publishedVersionedModel) throws PortalException
      Deletes the VersionedModel. Related drafts and versions are also deleted. Any VersionServiceListener that has been registered is notified. An IllegalArgumentException is thrown if the versioned model is a draft. Drafts can be deleted by calling deleteDraft(VersionedModel).
      Parameters:
      publishedVersionedModel - the published versioned model
      Returns:
      the versioned model that is deleted
      Throws:
      PortalException - if a portal exception occurred
    • deleteDraft

      E deleteDraft(E draftVersionedModel) throws PortalException
      Deletes the VersionedModel if it is a draft. Any VersionServiceListener that has been registered is notified. An IllegalArgumentException is thrown if the versioned model is not a draft. Published versioned models can be deleted by calling delete(VersionedModel).
      Parameters:
      draftVersionedModel - the draft versioned model
      Returns:
      the versioned model that is deleted
      Throws:
      PortalException - if a portal exception occurred
    • deleteVersion

      V deleteVersion(V versionModel) throws PortalException
      Deletes the VersionModel if it is not the latest version. Any VersionServiceListener that has been registered is notified. An IllegalArgumentException is thrown if the versioned model is the latest version.
      Parameters:
      versionModel - the version model
      Returns:
      the version model that is deleted
      Throws:
      PortalException - if a portal exception occurred
    • fetchDraft

      E fetchDraft(E versionedModel)
      Fetches the draft if it exists; otherwise, returns null.
      Parameters:
      versionedModel - the draft or published versioned model
      Returns:
      the draft versioned model if it exists; otherwise null
    • fetchDraft

      E fetchDraft(long primaryKey)
      Fetches the draft if it exists; otherwise, returns null.
      Parameters:
      primaryKey - the draft or published versioned model's primary key
      Returns:
      the draft versioned model if it exists; otherwise null
    • fetchLatestVersion

      V fetchLatestVersion(E versionedModel)
      Fetches the latest version model if it exists. If the versioned model has never been published, null is returned.
      Parameters:
      versionedModel - the versioned model
      Returns:
      the latest version model if it exists; otherwise null
    • fetchPublished

      E fetchPublished(E versionedModel)
      Fetches the published versioned model if it exists. If the versioned model has never been published, null is returned.
      Parameters:
      versionedModel - the versioned model
      Returns:
      the published versioned model if it exists; otherwise null
    • fetchPublished

      E fetchPublished(long primaryKey)
      Fetches the published versioned model if it exists; otherwise, returns null.
      Parameters:
      primaryKey - the published versioned model's primary key
      Returns:
      the published versioned model if it exists; otherwise null
    • getDraft

      E getDraft(E versionedModel) throws PortalException
      Returns the versioned model draft. If the draft does not exist, it is lazily created, adding it to the database. If a draft is lazily created, any VersionServiceListener that has been registered is notified.
      Parameters:
      versionedModel - the versioned model
      Returns:
      the versioned model
      Throws:
      PortalException - if a portal exception occurred
    • getDraft

      E getDraft(long primaryKey) throws PortalException
      Returns the versioned model draft with the primary key. If it does not exist, a new draft is lazily created and added to the database. If a draft is lazily created, any VersionServiceListener that has been registered is notified.
      Parameters:
      primaryKey - of the draft or published versioned model
      Returns:
      the versioned model
      Throws:
      PortalException - if no draft or published versioned model exists with the primary key
    • getVersion

      V getVersion(E versionedModel, int version) throws PortalException
      Returns the VersionModel for the VersionedModel matching the version.
      Parameters:
      versionedModel - the versioned model
      version - the version
      Returns:
      the version model
      Throws:
      PortalException - if the version does not exist
    • getVersions

      List<V> getVersions(E versionedModel)
      Returns the VersionModels for the VersionedModel. They are sorted in descending order.
      Parameters:
      versionedModel - the versioned model
      Returns:
      the version models
    • publishDraft

      E publishDraft(E draftVersionedModel) throws PortalException
      Publishes the draft and creates a new version model for the new version. Any VersionServiceListener that has been registered is notified. An IllegalArgumentException is thrown if the versioned model is not a draft.
      Parameters:
      draftVersionedModel - the draft version model
      Returns:
      the published versioned model
      Throws:
      PortalException - if a portal exception occurred
    • registerListener

      void registerListener(VersionServiceListener<E,V> versionServiceListener)
      Registers the VersionServiceListener.
      Parameters:
      versionServiceListener - the version service listener to register
    • unregisterListener

      void unregisterListener(VersionServiceListener<E,V> versionServiceListener)
      Unregisters the VersionServiceListener.
      Parameters:
      versionServiceListener - the version service listener to unregister
    • updateDraft

      E updateDraft(E draftVersionedModel) throws PortalException
      Updates the draft. Any VersionServiceListener that has been registered is notified. An IllegalArgumentException is thrown if the versioned model is not a draft.
      Parameters:
      draftVersionedModel - the draft version model
      Returns:
      the draft versioned model
      Throws:
      PortalException - if a portal exception occurred