public interface VersionService<E extends VersionedModel<V>,V extends VersionModel<E>>
VersionServiceListener
Modifier and Type | Method and Description |
---|---|
E |
checkout(E publishedVersionedModel,
int version)
Checks out the previous version of the versioned model and saves it as a
draft.
|
E |
create()
Creates a new draft
VersionedModel . |
E |
delete(E publishedVersionedModel)
Deletes the
VersionedModel . |
E |
deleteDraft(E draftVersionedModel)
Deletes the
VersionedModel if it is a draft. |
V |
deleteVersion(V versionModel)
Deletes the
VersionModel if it is not the latest version. |
E |
fetchDraft(E versionedModel)
Fetches the draft if it exists; otherwise, returns
null . |
E |
fetchDraft(long primaryKey)
Fetches the draft if it exists; otherwise, returns
null . |
V |
fetchLatestVersion(E versionedModel)
Fetches the latest version model if it exists.
|
E |
fetchPublished(E versionedModel)
Fetches the published versioned model if it exists.
|
E |
fetchPublished(long primaryKey)
Fetches the published versioned model if it exists; otherwise, returns
null . |
E |
getDraft(E versionedModel)
Returns the versioned model draft.
|
E |
getDraft(long primaryKey)
Returns the versioned model draft with the primary key.
|
V |
getVersion(E versionedModel,
int version)
Returns the
VersionModel for the VersionedModel matching
the version. |
java.util.List<V> |
getVersions(E versionedModel)
Returns the
VersionModel s for the VersionedModel . |
E |
publishDraft(E draftVersionedModel)
Publishes the draft and creates a new version model for the new version.
|
void |
registerListener(VersionServiceListener<E,V> versionServiceListener)
Registers the
VersionServiceListener . |
void |
unregisterListener(VersionServiceListener<E,V> versionServiceListener)
Unregisters the
VersionServiceListener . |
E |
updateDraft(E draftVersionedModel)
Updates the draft.
|
E checkout(E publishedVersionedModel, int version) throws PortalException
VersionServiceListener
that has been registered is
also notified. An IllegalArgumentException
is thrown if the
versioned model already has a draft.publishedVersionedModel
- the published versioned modelversion
- the versionVersionModel
being checked outPortalException
- if the version does not existE create()
VersionedModel
. The versioned model is not
added to the database.E delete(E publishedVersionedModel) throws PortalException
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)
.publishedVersionedModel
- the published versioned modelPortalException
- if a portal exception occurredE deleteDraft(E draftVersionedModel) throws PortalException
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)
.draftVersionedModel
- the draft versioned modelPortalException
- if a portal exception occurredV deleteVersion(V versionModel) throws PortalException
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.versionModel
- the version modelPortalException
- if a portal exception occurredE fetchDraft(E versionedModel)
null
.versionedModel
- the draft or published versioned modelnull
E fetchDraft(long primaryKey)
null
.primaryKey
- the draft or published versioned model's primary keynull
V fetchLatestVersion(E versionedModel)
null
is returned.versionedModel
- the versioned modelnull
E fetchPublished(E versionedModel)
null
is returned.versionedModel
- the versioned modelnull
E fetchPublished(long primaryKey)
null
.primaryKey
- the published versioned model's primary keynull
E getDraft(E versionedModel) throws PortalException
VersionServiceListener
that has been registered is notified.versionedModel
- the versioned modelPortalException
- if a portal exception occurredE getDraft(long primaryKey) throws PortalException
VersionServiceListener
that has been
registered is notified.primaryKey
- of the draft or published versioned modelPortalException
- if no draft or published versioned model exists
with the primary keyV getVersion(E versionedModel, int version) throws PortalException
VersionModel
for the VersionedModel
matching
the version.versionedModel
- the versioned modelversion
- the versionPortalException
- if the version does not existjava.util.List<V> getVersions(E versionedModel)
VersionModel
s for the VersionedModel
. They
are sorted in descending order.versionedModel
- the versioned modelE publishDraft(E draftVersionedModel) throws PortalException
VersionServiceListener
that has been registered is notified.
An IllegalArgumentException
is thrown if the versioned model is
not a draft.draftVersionedModel
- the draft version modelPortalException
- if a portal exception occurredvoid registerListener(VersionServiceListener<E,V> versionServiceListener)
VersionServiceListener
.versionServiceListener
- the version service listener to registervoid unregisterListener(VersionServiceListener<E,V> versionServiceListener)
VersionServiceListener
.versionServiceListener
- the version service listener to unregisterE updateDraft(E draftVersionedModel) throws PortalException
VersionServiceListener
that has been
registered is notified. An IllegalArgumentException
is thrown if
the versioned model is not a draft.draftVersionedModel
- the draft version modelPortalException
- if a portal exception occurred