public interface Versioned
Object versioning in Confluence works in a slightly unconventional way. The identity of the 'current' object (known in the interface as the 'original' or 'latest' version) always remains the same. The object's version history consists of cloned snapshots of that object, taken before each change to its state.
Or, to give a code example:
Versioned oldVersion = (Versioned) currentObject.clone(); oldVersion.convertToHistoricalVersion(); oldVersion.setOriginalVersion(currentObject); // make changes to currentObject currentVersion.setVersion(currentVersion.getVersion() + 1); // save both objects
For Confluence persistent objects, some of the above may be handled for you by the default DAO.
Modifier and Type | Method and Description |
---|---|
void |
applyChildVersioningPolicy(Versioned versionToPromote,
ObjectDao dao)
If
getVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType) specifies so, moves content from versionToPromote to this Versioned instance or
makes no change. |
void |
convertToHistoricalVersion()
Remove all data from the object that does not need to be saved by historical versions.
|
Versioned |
getLatestVersion()
Get the latest, current version of this versioned object.
|
ConfluenceEntityObject |
getOriginalVersion()
Deprecated.
since 2.5. Use
getLatestVersion() and isLatestVersion() instead. |
int |
getVersion()
Return the version number of this version of the object.
|
VersionChildOwnerPolicy |
getVersionChildPolicy(ContentType contentType)
Returns the right
VersionChildOwnerPolicy depending on the passed contentType. |
boolean |
isLatestVersion()
Is this the latest version of the object? If this method returns true, then
getOriginalVersion() will return null. |
boolean |
isNew()
Is this the first version of this object?
|
void |
setOriginalVersion(Versioned originalVersion)
Set the current version of this object.
|
void |
setVersion(int version)
Set the version number of this version of the object.
|
int getVersion()
void setVersion(int version)
version
- the new version number for this version of the object.void convertToHistoricalVersion()
When using Hibernate to persist versioned objects, take special care to null any field that might contain a Hibernate-persisted collection, as Hibernate does not allow two different persistent objects to refer to the same persisted collection at the same time.
void applyChildVersioningPolicy(@Nullable Versioned versionToPromote, ObjectDao dao)
getVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType)
specifies so, moves content from versionToPromote to this Versioned instance or
makes no change.versionToPromote
- the new version of the current instance that we're getting the children fromdao
- dao used to delete dangling contained contentboolean isNew()
@Deprecated ConfluenceEntityObject getOriginalVersion()
getLatestVersion()
and isLatestVersion()
instead.
Deprecated: This method is broken because it returns ConfluenceEntityObject
instead of Versioned
. In some future version of Confluence, this mistake will be
corrected, but the change will at the very least require that any code calling this method be
recompiled.
Versioned getLatestVersion()
Note that drafts are a special version of a ContentEntityObject
so for drafts this method should return the ContentEntityObject
the drafts points to if it exists and the draft itself otherwise.
ContentEntityObject.DRAFT
void setOriginalVersion(Versioned originalVersion)
originalVersion
- the current version of this object.boolean isLatestVersion()
getOriginalVersion()
will return null.VersionChildOwnerPolicy getVersionChildPolicy(ContentType contentType)
VersionChildOwnerPolicy
depending on the passed contentType.
By default, VersionChildOwnerPolicy.currentVersion
is returned
Right now, this is only enforced for children with content type Attachment or Comment
Copyright © 2003–2016 Atlassian. All rights reserved.