Interface Versioned
-
- All Known Implementing Classes:
AbstractLabelableEntityObject
,AbstractPage
,AbstractVersionedEntityObject
,Attachment
,BlogPost
,Comment
,ContentEntityObject
,CustomContentEntityObject
,Draft
,GlobalDescription
,Page
,PageTemplate
,PersonalInformation
,SpaceContentEntityObject
,SpaceDescription
public interface Versioned
A Confluence object that can exist in multiple versions. Only a single history of versions is allowed for any object: branching versions are not supported.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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
applyChildVersioningPolicy(@Nullable Versioned versionToPromote, ObjectDao dao)
Deprecated.since 6.10.0.void
applyChildVersioningPolicy(@Nullable Versioned versionToPromote, ObjectDaoInternal<?> dao)
IfgetVersionChildPolicy(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.int
getVersion()
Return the version number of this version of the object.VersionChildOwnerPolicy
getVersionChildPolicy(ContentType contentType)
Returns the rightVersionChildOwnerPolicy
depending on the passed contentType.boolean
isLatestVersion()
boolean
isNew()
Is this the first version of this object?void
setOriginalVersion(Versioned originalVersion)
Deprecated.since 7.0.0void
setVersion(int version)
Set the version number of this version of the object.
-
-
-
Method Detail
-
getVersion
int getVersion()
Return the version number of this version of the object. Version numbers are integers in ascending chronological order from 1 (the first version). Clients must not assume if two versions x and y exist, that any integer versions between x and y also exist.- Returns:
- the version number of this version of the object
-
setVersion
void setVersion(int version)
Set the version number of this version of the object. Only call this method if you are creating a new version.- Parameters:
version
- the new version number for this version of the object.
-
convertToHistoricalVersion
void convertToHistoricalVersion()
Remove all data from the object that does not need to be saved by historical versions. For versioned objects that are persisted, this includes removing associations with other persisted objects that may otherwise cause us to break the expected arity of the database relations.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.
-
applyChildVersioningPolicy
@Deprecated void applyChildVersioningPolicy(@Nullable Versioned versionToPromote, ObjectDao dao)
Deprecated.since 6.10.0. UseapplyChildVersioningPolicy(Versioned, ObjectDaoInternal)
instead.IfgetVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType)
specifies so, moves content from versionToPromote to this Versioned instance or makes no change.- Parameters:
versionToPromote
- the new version of the current instance that we're getting the children fromdao
- dao used to delete dangling contained content
-
applyChildVersioningPolicy
void applyChildVersioningPolicy(@Nullable Versioned versionToPromote, ObjectDaoInternal<?> dao)
IfgetVersionChildPolicy(com.atlassian.confluence.api.model.content.ContentType)
specifies so, moves content from versionToPromote to this Versioned instance or makes no change.- Parameters:
versionToPromote
- the new version of the current instance that we're getting the children fromdao
- dao used to delete dangling contained content
-
isNew
boolean isNew()
Is this the first version of this object?- Returns:
- true if this is the first version of this versioned object, false if it is a later version.
-
getLatestVersion
Versioned getLatestVersion()
Get the latest, current version of this versioned object. If this object is the current version, return this object.Note that drafts are a special version of a
ContentEntityObject
so for drafts this method should return theContentEntityObject
the drafts points to if it exists and the draft itself otherwise.- Returns:
- the current version of this object.
- See Also:
ContentEntityObject.DRAFT
-
setOriginalVersion
@Deprecated void setOriginalVersion(Versioned originalVersion)
Deprecated.since 7.0.0Set the current version of this object. After this method is called, this object will become an historical version of the object passed in.- Parameters:
originalVersion
- the current version of this object.
-
isLatestVersion
boolean isLatestVersion()
- Returns:
- true if this is the latest (current) version of the object, false if it is an historical version.
-
getVersionChildPolicy
VersionChildOwnerPolicy getVersionChildPolicy(ContentType contentType)
Returns the rightVersionChildOwnerPolicy
depending on the passed contentType. By default,VersionChildOwnerPolicy.currentVersion
is returnedRight now, this is only enforced for children with content type Attachment or Comment
-
-