public interface

Versioned

com.atlassian.confluence.core.Versioned
Known Indirect Subclasses

Class Overview

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.

Summary

Public Methods
abstract void convertToHistoricalVersion()
Remove all data from the object that does not need to be saved by historical versions.
abstract Versioned getLatestVersion()
Get the latest, current version of this versioned object.
abstract ConfluenceEntityObject getOriginalVersion()
This method is deprecated. since 2.5. Use getLatestVersion() and isLatestVersion() instead.
abstract int getVersion()
Return the version number of this version of the object.
abstract boolean isLatestVersion()
Is this the latest version of the object? If this method returns true, then getOriginalVersion() will return null.
abstract boolean isNew()
Is this the first version of this object?
abstract void setOriginalVersion(Versioned originalVersion)
Set the current version of this object.
abstract void setVersion(int version)
Set the version number of this version of the object.

Public Methods

public abstract 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.

public abstract Versioned getLatestVersion ()

Get the latest, current version of this versioned object. If this object is the current version, return this object.

Returns
  • the current version of this object.

public abstract ConfluenceEntityObject getOriginalVersion ()

This method is deprecated.
since 2.5. Use getLatestVersion() and isLatestVersion() instead.

Get the "original version" of this versioned object. If this object is the original version, return null.

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.

Returns
  • the original version of this versioned object, or null if this is the original version.

public abstract 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

public abstract boolean isLatestVersion ()

Is this the latest version of the object? If this method returns true, then getOriginalVersion() will return null.

Returns
  • true if this is the latest (current) version of the object, false if it is an historical version.

public abstract 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.

public abstract void setOriginalVersion (Versioned originalVersion)

Set 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.

public abstract 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.