AnsweredAssumed Answered

Custom properties not set via CMIS createDocument

Question asked by vvstraet on Aug 28, 2012
Latest reply on Mar 8, 2013 by stevegreenbaum
I've noticed a couple of threads on this behavior, but I have yet to find a working solution. So here goes another try …

The requirements:
I need to use the CMIS webservices (URL: http://localhost:8080/alfresco/cmis) in order to update content in a repository.
Furthermore, a custom aspect has to be set upon creation which will then be used in searches in the repository.

The problem:
I can successfully create the document and the aspect is added, but the associated properties (which are also included in the request) are "null" after the operation. The document is also not retrieved when using the custom properties in searches. When manually updating the properties in Alfresco Share, the documents are successfully found when searching on the custom properties.

The environment:
Alfresco 4.0e CE on Windows 7 64-bit; 
apache-chemistry-opencmis-client 0.7.0 & alfresco-opencmis-extension 0.3

The custom model:
<?xml version="1.0" encoding="UTF-8"?>
<model name="dm:demoModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!– File goes in shared/classes/alfresco/extension –>
    …
    <!– Imports are required to allow references to definitions in other models –>
    <imports>
        <!– Import Alfresco Dictionary Definitions –>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
        <!– Import Alfresco Content Domain Model Definitions –>
        <import uri="http://www.alfresco.org/model/content/1.0"  prefix="cm" />
        <!– Import Alfresco Content Domain Model Definitions –>
        <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" />
        <import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl" />
    </imports>

    <!– Sites Namespace –>
    <namespaces>
        <namespace uri="http://www.alfresco.org/model/gdomodel/1.0" prefix="dm" />
    </namespaces>

   <!– Custom aspects –>
    <aspects>
        <aspect name="dm:dossier">
            <title>Dossier</title>
            <properties>
                <property name="dm:dossiertype">
                    <title>Dossiertype</title>
                    <type>d:text</type>
                </property>
                <property name="dm:dossiernummer">
                    <title>Dossiernummer</title>
                    <type>d:text</type>
                </property>
            </properties>
        </aspect>
     </aspects>
</model>

A print of the properties that are sent to the CMIS client (with Alfresco extension):
{dm:dossiernummer=54321, cmis:objectTypeId=cmis:document,P:dm:dossier, cmis:name=test4.txt, dm:dossiertype=AB}

The code for setting these properties:
Map<String, Object> cmisProperties = new HashMap<String, Object>();

      String documentType = null;
      String aspectType = null;
      for( DMSObjectEigenschap eigenschap : eigenschappen ) {
         if( eigenschap.getEigenschap().equals(EigenschapType.DOCUMENT_TYPE) ) {
            documentType = "D:" + eigenschap.getWaarde();
         } else if( eigenschap.getEigenschap().equals(EigenschapType.DOSSIER_TYPE) ) {
            aspectType ="P:dm:dossier";
            cmisProperties.put("dm:dossiertype", eigenschap.getWaarde());
         } else if( eigenschap.getEigenschap().equals(EigenschapType.DOSSIER_NUMMER) ) {
            cmisProperties.put("dm:dossiernummer", eigenschap.getWaarde());
         }
      }

      cmisProperties.put(PropertyIds.OBJECT_TYPE_ID,
            (documentType == null ? CMISConstants.CMIS_BASETYPE_DOC : documentType)
            + (aspectType == null ? "" : "," + aspectType));
      cmisProperties.put(PropertyIds.NAME, naam);

The code for the "createDocument" call itself:
ContentStream contentStream = …
            Document newDoc = ((Folder) destinationFolder)
                  .createDocument(cmisProperties, contentStream, VersioningState.MAJOR);


The problem is that I cannot find any exceptions in any logging, the call is successfully performed but the properties are NOT set.
Any thoughts?

Outcomes