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 Summary
Modifier and TypeMethodDescriptionChecks out the previous version of the versioned model and saves it as a draft.create()
Creates a new draftVersionedModel
.Deletes theVersionedModel
.deleteDraft
(E draftVersionedModel) Deletes theVersionedModel
if it is a draft.deleteVersion
(V versionModel) Deletes theVersionModel
if it is not the latest version.fetchDraft
(long primaryKey) Fetches the draft if it exists; otherwise, returnsnull
.fetchDraft
(E versionedModel) Fetches the draft if it exists; otherwise, returnsnull
.fetchLatestVersion
(E versionedModel) Fetches the latest version model if it exists.fetchPublished
(long primaryKey) Fetches the published versioned model if it exists; otherwise, returnsnull
.fetchPublished
(E versionedModel) Fetches the published versioned model if it exists.getDraft
(long primaryKey) Returns the versioned model draft with the primary key.Returns the versioned model draft.getVersion
(E versionedModel, int version) Returns theVersionModel
for theVersionedModel
matching the version.getVersions
(E versionedModel) Returns theVersionModel
s for theVersionedModel
.publishDraft
(E draftVersionedModel) Publishes the draft and creates a new version model for the new version.void
registerListener
(VersionServiceListener<E, V> versionServiceListener) Registers theVersionServiceListener
.void
unregisterListener
(VersionServiceListener<E, V> versionServiceListener) Unregisters theVersionServiceListener
.updateDraft
(E draftVersionedModel) Updates the draft.
-
Method Details
-
checkout
Checks out the previous version of the versioned model and saves it as a draft. AnyVersionServiceListener
that has been registered is also notified. AnIllegalArgumentException
is thrown if the versioned model already has a draft.- Parameters:
publishedVersionedModel
- the published versioned modelversion
- the version- Returns:
- the draft
VersionModel
being checked out - Throws:
PortalException
- if the version does not exist
-
create
E create()Creates a new draftVersionedModel
. The versioned model is not added to the database.- Returns:
- the new draft versioned model
-
delete
Deletes theVersionedModel
. Related drafts and versions are also deleted. AnyVersionServiceListener
that has been registered is notified. AnIllegalArgumentException
is thrown if the versioned model is a draft. Drafts can be deleted by callingdeleteDraft(VersionedModel)
.- Parameters:
publishedVersionedModel
- the published versioned model- Returns:
- the versioned model that is deleted
- Throws:
PortalException
- if a portal exception occurred
-
deleteDraft
Deletes theVersionedModel
if it is a draft. AnyVersionServiceListener
that has been registered is notified. AnIllegalArgumentException
is thrown if the versioned model is not a draft. Published versioned models can be deleted by callingdelete(VersionedModel)
.- Parameters:
draftVersionedModel
- the draft versioned model- Returns:
- the versioned model that is deleted
- Throws:
PortalException
- if a portal exception occurred
-
deleteVersion
Deletes theVersionModel
if it is not the latest version. AnyVersionServiceListener
that has been registered is notified. AnIllegalArgumentException
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
Fetches the draft if it exists; otherwise, returnsnull
.- Parameters:
versionedModel
- the draft or published versioned model- Returns:
- the draft versioned model if it exists; otherwise
null
-
fetchDraft
Fetches the draft if it exists; otherwise, returnsnull
.- Parameters:
primaryKey
- the draft or published versioned model's primary key- Returns:
- the draft versioned model if it exists; otherwise
null
-
fetchLatestVersion
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
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
Fetches the published versioned model if it exists; otherwise, returnsnull
.- Parameters:
primaryKey
- the published versioned model's primary key- Returns:
- the published versioned model if it exists; otherwise
null
-
getDraft
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, anyVersionServiceListener
that has been registered is notified.- Parameters:
versionedModel
- the versioned model- Returns:
- the versioned model
- Throws:
PortalException
- if a portal exception occurred
-
getDraft
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, anyVersionServiceListener
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
Returns theVersionModel
for theVersionedModel
matching the version.- Parameters:
versionedModel
- the versioned modelversion
- the version- Returns:
- the version model
- Throws:
PortalException
- if the version does not exist
-
getVersions
Returns theVersionModel
s for theVersionedModel
. They are sorted in descending order.- Parameters:
versionedModel
- the versioned model- Returns:
- the version models
-
publishDraft
Publishes the draft and creates a new version model for the new version. AnyVersionServiceListener
that has been registered is notified. AnIllegalArgumentException
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
Registers theVersionServiceListener
.- Parameters:
versionServiceListener
- the version service listener to register
-
unregisterListener
Unregisters theVersionServiceListener
.- Parameters:
versionServiceListener
- the version service listener to unregister
-
updateDraft
Updates the draft. AnyVersionServiceListener
that has been registered is notified. AnIllegalArgumentException
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
-