javaalfrescoopencmis

Alfresco aspect secondaryType


I have a probleme with openCmis with Alfresco in Java. I try to add a secondaryType "abc:aspectCustom" to my document like we can see in this code :

props.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_DOCUMENT.value());
    props.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, Arrays.asList("P:abc:aspectCustom"));
    ContentStream contentStream = session.getObjectFactory().createContentStream(documentName, sizeFolder, typeFile, inputStream);
    Document document = targetFolder.createDocument(props, contentStream, VersioningState.CHECKEDOUT);

but i have this error :

java.lang.IllegalArgumentException: Secondary types property contains a type that is not a secondary type: P:abc:aspectCustom

So i tried to debug and i see that my problem come from this part of code (ObjectFactoryImpl) :

if (!(secondaryType instanceof SecondaryType)) {
                    throw new IllegalArgumentException(
                            "Secondary types property contains a type that is not a secondary type: " + secondaryTypeId);
                }

and when i debug the secondaryType object i see that he's instance of PolicyType and not SecondaryType. So i dont now where is the probleme ! why my aspect in the model is interpreted as a Policy and not as a SecondaryType.

For information, in the model Alfresco i have this :

<aspect name="abc:aspectCustom">
            <title>ABCAspect</title>
</aspect> 

Thnakk you :)


Solution

  • First, make sure that you are using the CMIS 1.1 service URL, which is https://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom for the ATOMPub binding and https://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser for the Browser binding.

    Next, try adding an out-of-the-box aspect, like P:cm:geographic, instead of your custom aspect, just to make sure that works. This will rule out any problems with your custom content model.