Pages

Tuesday, January 17, 2017

How to copy all versions of a documentum object if the root version in the object version hierarchy is deleted?

Suppose a documentum object has many versions. It is easy to copy such an object while preserving its version tree. For example, probably the easiest possible approach is described here. The described method will work even if the root version in the source object has been previously deleted. But the copies will not be entirely valid. For example, they will be undeletable by normal means.

When the root version is deleted, chronicle id of all its descendants are not changed even though the root version becomes inaccessible. To produce the valid objects, I treat the oldest existing version as the root version - its copy id serves as the chronicle in the producted copies of the source versions.

    Map<IDfId, IDfId> copyAllObjectsWithChronicleId(IDfId chronicleId, IDfSession sourceSession) throws DfException {
        // list ordered by r_creation_date and r_object_id
        List<IDfId> idsWithChronicleId = getAllVersionIdsWithChronicleId(sourceSession, chronicleId);
        Map<IDfId, IDfId> missingSourceObjIdCopyObjIds = new HashMap<IDfId, IDfId>();

        // missing because it was deleted
        if (idsWithGivenChronicleId.contains(chronicleId)) {
            logger.debug("the root version is intact");
        } else {
            // the root object is deleted, so the oldest existing its version will substitute it
            logger.debug("the version is missing");
            missingSourceObjIdCopyObjIds.put(chronicleId, idsWithGivenChronicleId.get(0));
        }
        ..... // copy data, contents and version-related attributes
    }

I use the map-based approach also for exact replication of virtual documents or objects together with all their parent folder paths whereby the existing paths are reused whereas missing paths are created.

No comments:

Post a Comment