cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with custom Aspects (CMIS Policy)

jawwad
Champ in-the-making
Champ in-the-making
Hi,

      I just created a custom model (book) in Alfresco 3.4.1. It includes a type b:bookType and an aspect b:bookPublication. Now both are present in the repository with the names D:b:bookType (a content type under cmis:document) and P:b:bookPublication (under cmisSmiley Tongueolicy)respectively. The D:b:bookType works fine but I cant figure out how to use the P:b:bookPublication. coz when i try to create a new policy using:

      properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_POLICY.value());
      properties.put(PropertyIds.NAME, policyType.getId());
      
      
      Policy policy = customFolder.createPolicy(properties);

it returns error: Exception in thread "main" java.lang.IllegalArgumentException: Property +'cmisSmiley SurprisedbjectTypeId' is not valid for this type!

and I cant find a way to retrieve it as a Policy object. So plz can anyone tell me what should I do or what am I doing wrong?

Any help will be highly appreciated. Thanks in advance.
3 REPLIES 3

fmui
Champ in-the-making
Champ in-the-making
Hi Jawwad,

The Alfresco OpenCMIS Extension gives you access to aspects: http://apache-extras.org/p/alfresco-opencmis-extension

Florian

jawwad
Champ in-the-making
Champ in-the-making
Hi and Thanks Florian,

         I tried the Alfresco OpenCMIS Extension but now im having a class cast exception. My code is:

      
Document existingBook = (Document)session.getObject(bookTypeDoc);
      AlfrescoDocument alfDoc = (AlfrescoDocument)existingBook;
      alfDoc.addAspect("P:b:bookPublication");
      if(alfDoc.hasAspect("P:b:bookPublication")){
         properties.put("b:publishedBy", "Custom CMIS");
         alfDoc.updateProperties(properties);
      }

           Here the Document im retrieving is of a custom type (D:b:bookType). and the exception is:
"
Exception in thread "main" java.lang.ClassCastException: org.apache.chemistry.opencmis.client.runtime.DocumentImpl cannot be cast to org.alfresco.cmis.client.AlfrescoDocument"
On this code
AlfrescoDocument alfDoc = (AlfrescoDocument)existingBook;

            Same happens when I try to cast a general non-custom type. Can you plz help me on this?

Thanks in advance.

jawwad
Champ in-the-making
Champ in-the-making
Hi,

         Sorry,  I found my mistake   Smiley Happy . I was missing this session parameter entry.

params.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");

          Thanks again