AnsweredAssumed Answered

First version of a document doesn't have aspect values

Question asked by sepgs2004 on Jul 18, 2018
Latest reply on Jul 19, 2018 by sepgs2004

In code, I use CMIS to communicate with Alfresco 5.1.x community edition. I followed "CMIS and Apache Chemistry in Action" book. 

We have our own custom model defined, whose parent is cm:content. Our model has its own (custom meta-data) set of properties. This is defined as an aspect

Things are working good in general. I have one issue that I could not figure out. This is with respect to versions. When I view the version history, the first version (oldest version), does not have our custom meta-data (aspect) properties set. However, the later versions have values for these properties. 

It is the same code that creates versions whenever in needed.

Do you know how could this happen?

In the attachments, please see the version 1.0. It does not have values for the aspect properties. 

Whereas, the version 2.0 has the values populated.


It does not matter how many versions I end up creating, always the very first version that Alfresco creates does not have the aspect values populated. 




    Document existingDocument = getAlfrescoCMISDocumentByProperties(uniqueProperties, user);
    if (existingDocument.isVersionSeriesCheckedOut()) {
    // Check out the document
    ObjectId documentOjectId = existingDocument.checkOut();
    insertDocument = (Document) cmisSession.getObject(documentOjectId);
    String mimeType = "application/octet-stream";
    if (mDocument.getMimeType() != null) {
     mimeType = mDocument.getMimeType();
    InputStream stream = null;
    try {
     byte[] content = mDocument.getBData();
     stream = new ByteArrayInputStream(content);
     ContentStream contentStream = cmisSession.getObjectFactory().createContentStream(
       mDocument.getFileName(), Long.valueOf(content.length), mimeType, stream);
     cmisProperties = document2AlfrescoDocumentProperties(mDocument, true);
     ObjectId insertedDocumentObjectId = insertDocument.checkIn(true, cmisProperties, contentStream, user);
     CmisObject insertedDocument = (Document) cmisSession.getObject(insertedDocumentObjectId);
    catch (Exception inExc) {
     message = "Error occurred while uploading a new version of the document [" + (namePropertyValue == null ? "" : namePropertyValue) + "] - " + inExc.getMessage();
    finally {
     if (stream != null) { try { stream.close(); } catch (Exception e) {} }