140 Chapter 11. Services Tutorials
11.5.3. Recoverable types
The case of compound attributes like country is a little more complex. Let’s look at Example 11-8
again. Suppose the Great Quux had Wonderland listed as his country of residence on Jan 19. On Apr
12, his country of residence changed to Eriador; the Wonderland data object was deleted altogether.
What should happen if we try to rollback the Great Quux to his Jan 19 state? Since the data object
is versioned, its country attribute should be rolled back to Wonderland. But Wonderland no longer
exits in the database. One solution is to set the country to null. This would not work in this case,
because this attribute is required - it has the multiplicity of 1..1. Therefore, we should be able to
recover the deleted data object.
This leads to the notion of a recoverable data object. A data object is recoverable if the versioning
service is able to undelete it after it has been deleted. Being recoverable is a weaker requirement than
being fully versioned. The versioning service may not be able to rollback a recoverable object back
to an arbitrary point in its history, but it should record enough information to undelete it, in case it is
ever deleted.
The versioning service infers that if a versioned object type has a required compound attribute,
then the object type of the attribute must be marked as recoverable. The versioning service does
not normally record changes to recoverable objects, but it keeps track of them incase they are deleted.
If a recoverable object is deleted, the versioning service records the last known values of its attributes
in order to be able to undelete it.
What does this mean in terms of Example 11-8? The versioning service treats the Country object
type as recoverable,because it is a required compound attribute of the versioned type GreatQuux.
Why not make the Country object type fully versioned? Because we don’t want to version more
data thanis actually needed.If adeveloper wantsto make theCountryobject type fullyversioned,
they should explicitly mark it as such in the PDL definition.
What if the Country object type is marked as versioned? Should we rollback the country
attribute when we rollback the Great Quux object? We cannot. Since it is not a component of
GreatQuux, Country data objects may be included as an attribute by other object types. If we
rollback a country as part of rolling back the Great Quux object, we may affect a lot of other objects
that should not have been necessarily affected by this rollback.
11.5.4. Versioning service API
For backwards compatibility, some of the old versioning APIs are preserved. For example, you can
tag the state of a data object in the current transaction by calling the applyTag method on the Ver-
sionedACSObject class. However, this class has been deprecated.
The preferred point of entry into the API provided by the versioning service is the Versions class.
One important capability it has is providing methods for invoking the following functionalities:
1. Tagging the state of a data object in the current transaction. Note that you can tag the state of a
data object, even if no changes were made to it in the current transaction. You can also tag more
than one data object within the same transaction.
2. You can retrieve a collection of tagged transactions for a data object. Note that since the data
object may have been deleted, themethod for retrieving the collection takes in anOID parameter
rather than a DataObject parameter.
3. You can roll a data object back to any previous point in its history.
4. You can compute the difference between any two states of a data object.
5. You can suspend versioning till the end of the current transaction.
Please refer to the Javadoc API at http://rhea.redhat.com/documentation/api/ccm-core-6.1.0 for de-
tails.