Why does copyContents() method of documentModelImpl class ignore a metaData change if its value has been removed from the source document.
Why does copyContents ignore a metaData change if its value has been removed from the source document.
I see that while calling the copyContents method, if the dataModel encounters a empty or null value, it moves ahead without replacing the destination field with the NULL value.
Was there any specific reason for doing like this? I thought of modifying the underlying logic. But i m not able to build and replace the NUXEO_CORE_API jar in my local bundles folder.
Changed copyContents() method can be found below
public static DataModel cloneDataModel(Schema schema, DataModel data) {
DataModel dm = new DataModelImpl(schema.getName());
for (Field field : schema.getFields()) {
String key = field.getName().getLocalName();
Object value;
try {
value = data.getData(key);
} catch (PropertyException e1) {
continue;
}
Object clone =null;
if (value != null) {
clone = cloneField(field, key, value);
}
try {
dm.setData(key, clone);
} catch (PropertyException e) {
throw new ClientRuntimeException(e);
}
}
return dm;
}
0 votes
0 answers
1679 views
copyContent
to copy data from an existingDocumentModel
into a newly-created empty one, so the current behavior is correct in my opinion.But in our use case, we were trying to copyContents into an existing document. To explain the scenario from the top, We wanted to copy documents from one repo into another. During that process we could not use the existing copy operation which is limited to a repository. So, we went ahead with a custom operation which performs the job of copying documents between repos. In the custom operation, we were creating a new doc and copying contents if the target repo does not contain the same document, otherwise we override the contents from source document into target document.
I hope this explains the question i had before. Thanks for responding back!!