cancel
Showing results for 
Search instead for 
Did you mean: 

Custom properties not set via CMIS createDocument

vvstraet
Champ in-the-making
Champ in-the-making
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, cmisSmiley SurprisedbjectTypeId=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?
3 REPLIES 3

vvstraet
Champ in-the-making
Champ in-the-making
Nobody having the same issue and/or possibly a solution?

vvstraet
Champ in-the-making
Champ in-the-making
It's been quiet around this topic for a while now. Revisited it myself and I finally got it working. The cause seemed to be the fact that a Xalan version was present on the classpath of my apache chemistry based client (with the alfresco extension).

After excluding it, I retried the call and found that the properties were all set!

I found this post while having a problem creating a document via CMIS with a custom aspect with properties.  I was receiving an XML parsing error (message: prefix cannot be null or empty).  I was running the code in Eclipse from a Alfreco v3.4 SDK against a v4.x repository.  Once I moved the project to a v4x SDK everything worked fine. 
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.