The Document V2 API described here looks promising: GetA12 Login
The docs describe how to create, read, update, serialize a document using V2.
What is never mentioned, though, is how to actually persist a created or updated document.
The only way I found so far looks like this:
public DocumentV2 createDocument(DocumentV2 documentV2) {
var documentV1V2Converter = documentServiceFactory.createDocumentV1V2Converter();
var documentV1 = documentV1V2Converter.toDocumentV1(documentV2);
var dataServicesDocument = documentService.create(documentV1, Locale.GERMANY);
var documentId = dataServicesDocument.getMetadata().getDocRef().getDocumentId();
var newDocumentV1 = dataServicesDocument.getKernelDocument();
newDocumentV1.setId(documentId);
return documentV1V2Converter.ofDocumentV1(newDocumentV1);
}
Two questions:
- Is there a way that avoids converting to and fro V1 documents?
- Why the is the ID still empty after calling
documentService.create()? (I have to set it manually.)