DFC checkinEx会错误地继承并合并来自上一版本的元数据,即使调用了setNull也仍然如此
我正在使用DFC(Java) 将FileNet迁移到Documentum (22.2)。在版本化时,我遇到了一个“Smart Merge”问题,即使我在私有工作副本(PWC)中明确尝试将元数据设为null,Documentum仍在静默地重新应用上一个版本的元数据。
The Environment:
Documentum 16.4 / 23.x (standard DFC)
Goal: Create a new Major Version (e.g., 1.0 -> 2.0) with entirely new metadata from a Map.
The Issue:
If Attribute_A has the value "005293" in Version 1.0, and my data map for Version 2.0 says this field should be NULL, the resulting Version 2.0 object still contains "005293".
My logs confirm the PWC is NULL in memory before checkin, but the checkin operation seems to "merge" or "carry forward" the old value because it sees it as an inherited attribute.
Current Code Logic:
java
// 1. Checkout
sysObj.checkout();
IDfSysObject pwc = (IDfSysObject) session.getObject(sysObj.getObjectId());
// 2. Content First (Requirement: Bind content before metadata)
pwc.setContentType(formatFromMap);
pwc.setContent(byteArrayOutputStream);
// 3. Metadata Loop (The "Brute Force" attempt)
for (String key : datamap.keySet()) {
Object val = datamap.get(key);
if (val == null || val.toString().isEmpty()) {
pwc.setNull(key);
if (pwc.isAttrRepeating(key)) pwc.removeAll(key);
} else {
pwc.setString(key, val.toString());
}
}
// 4. Checkin
// Note: Adding pwc.save() before this line throws DM_SYSOBJECT_E_NOT_CHECKEDOUT
IDfId newId = pwc.checkinEx(false, "2.0", "0", null, null, null);
Use code with caution.
What I have tried:
pwc.setNull(key): DFC ignores this during checkin and pulls the value from the previous version.
pwc.setString(key, " "): This "nudge" works for strings, but throws DM_API_E_BADDATE on date fields.
pwc.save() before checkin: This releases the lock in my environment, causing the checkin to fail with NOT_CHECKEDOUT.
The Question:
How can I programmatically "break" the inheritance link on a PWC so that checkinEx honors the NULL values provided in the current session instead of merging them from the version history? Is there a specific IDfVersionPolicy or hidden checkinEx flag to disable this "Smart Merge" behavior?
解决方案
您必须在将属性设为NULL之前强制进行属性转换。
模式
上一个值 -> 临时值 -> NULL
示例:
if (val == null || val.toString().isEmpty()) {
if (!pwc.isAttrRepeating(key)) {
// Force change
if (pwc.getAttrDataType(key) == IDfAttr.DM_STRING) {
pwc.setString(key, "__TEMP__");
}
if (pwc.getAttrDataType(key) == IDfAttr.DM_INTEGER) {
pwc.setInt(key, -999999);
}
if (pwc.getAttrDataType(key) == IDfAttr.DM_DOUBLE) {
pwc.setDouble(key, -999999.0);
}
if (pwc.getAttrDataType(key) == IDfAttr.DM_BOOLEAN) {
pwc.setBoolean(key, !pwc.getBoolean(key));
}
if (pwc.getAttrDataType(key) == IDfAttr.DM_TIME) {
IDfTime t = new DfTime("01/01/1900 00:00:00", IDfTime.DF_TIME_PATTERN44);
pwc.setTime(key, t);
}
// now set null
pwc.setNull(key);
} else {
pwc.removeAll(key);
}
}
这会强制Documentum将该属性标记为已修改,从而服务器会正确处理NULL。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。