AnsweredAssumed Answered

Using cmis, adding a new secondary type (aspect) removes association aspects, is this a bug?

Question asked by ianw on Oct 7, 2016
Latest reply on Oct 10, 2016 by ianw

The following groovy demonstrates the problem I'm having:

 

import org.apache.chemistry.opencmis.commons.*
import org.apache.chemistry.opencmis.commons.data.*
import org.apache.chemistry.opencmis.commons.enums.*
import org.apache.chemistry.opencmis.client.api.*

def cmis = new scripts.CMIS(session)
Folder folder  = cmis.getFolder("/Shared")
final String textFileName = "test.txt"

Document doc 
try{
    doc = (Document) session.getObjectByPath(folder.getPath()+"/"+textFileName)
}catch(Err){}
if (doc != null){
    doc.delete(true)
}

String mimetype = "text/plain; charset=UTF-8"
String content = "This is some test content"
String filename = textFileName

byte[] buf = content.getBytes("UTF-8")
ByteArrayInputStream input = new ByteArrayInputStream(buf)

ContentStream contentStream = session.getObjectFactory().createContentStream(filename, buf.length, mimetype, input)

Map<String, Object> props = new HashMap<String, Object>()
props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document")
props.put(PropertyIds.NAME, filename)

doc = folder.createDocument(props, contentStream, VersioningState.MAJOR)
    
List<String> aspects = doc.getPropertyValue("cmis:secondaryObjectTypeIds")
println(aspects)

List<String> toAdd 

props.clear()
if (!aspects.contains("R:ncsrel:related")) {
    toAdd = ["P:ncsrel:related"]
    doc = doc.updateProperties(props, toAdd, null)
}
aspects = doc.getPropertyValue("cmis:secondaryObjectTypeIds")
println(aspects)

//problem, adding this aspect removes the R:ncsrel:related
if (!aspects.contains("P:cm:dublincore")) {
    toAdd = ["P:cm:dublincore"]
    doc = doc.updateProperties(props, toAdd, null)
}
aspects = doc.getPropertyValue("cmis:secondaryObjectTypeIds")
println(aspects)








 

The output is:

[P:cm:titled, P:sys:localized, P:cm:author]

[P:cm:titled, R:ncsrel:related, P:sys:localized, P:cm:author]

[P:cm:titled, P:cm:dublincore, P:sys:localized, P:cm:author]

Adding P:cm:dublincore deleted R:ncsrel:related.

 

The R:ncsrel:related aspect definition:

 

    <aspects>
            <aspect name="ncsrel:related">
            <title>NCS Related</title>
            <associations>
                <association name="ncsrel:related">
                    <title>Related Content</title>
                    <source>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>cm:content</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>
            </associations>
        </aspect>
    </aspects>

c

cts>

 

Has anyone any thoughts?

Outcomes