5

I’m having problem while adding document with custom aspects (Alfresco 4.2e). It shows the following error:

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException: Type 'kb:referencable' is unknown!

Any help would be much appreciated.

These are my files:

sample.java

Map<String, String> props = new HashMap<String, String>();
    props.put(PropertyIds.NAME, newDocName);
    props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,kb:referencable");
    props.put("kb:documentRef", "My document");
    String content = "sample=================" ;
    byte[] buf = null;
    try {
        buf = content.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    ByteArrayInputStream input = new ByteArrayInputStream(buf);
    ContentStream contentStream = session.getObjectFactory()
            .createContentStream(newDocName, buf.length,
                    "text/plain; charset=UTF-8", input);
    target.createDocument(props, contentStream, VersioningState.MAJOR);

share-config-custom.xml

     <aspects>
     <!-- Aspects that a user can see -->
     <visible>
        <aspect name="cm:generalclassifiable" />
        <aspect name="cm:complianceable" />
        <aspect name="cm:dublincore" />
        <aspect name="cm:effectivity" />
        <aspect name="cm:summarizable" />
        <aspect name="cm:versionable" />
        <aspect name="cm:templatable" />
        <aspect name="cm:emailed" />
        <aspect name="emailserver:aliasable" />
        <aspect name="cm:taggable" />
        <aspect name="app:inlineeditable" />
        <aspect name="gd:googleEditable" />
        <aspect name="cm:geographic" />
        <aspect name="exif:exif" />
        <aspect name="audio:audio" />
        <aspect name="cm:indexControl" />
        <aspect name="dp:restrictable" />
        <aspect name="kb:referencable" />
     </visible>

     <!-- Aspects that a user can add. Same as "visible" if left empty -->
     <addable>
     </addable>

     <!-- Aspects that a user can remove. Same as "visible" if left empty -->
     <removeable>
     </removeable>
    </aspects>

custom-slingshot-application-context.xml.sample

 <bean id="webscripts.kb.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
  <property name="resourceBundles">
     <list>
        <value>alfresco.messages.knowledgebase</value>
     </list>
  </property>
 </bean>

web-client-config-custom.xml.sample

<config evaluator="aspect-name" condition="kb:referencable">
     <property-sheet>
         <show-property name="kb:documentRef"/>
    </property-sheet>
</config>
<config evaluator="string-compare" condition="Action Wizards">
    <aspects>
        <aspect name="my:docProps" />
    </aspects>
</config>

kb-model.xml

<aspects>
  <!-- Definition of new Content Aspect: Knowledge Base Document -->
  <aspect name="kb:referencable">
     <title>Knowledge Base Referencable</title>
     <properties>
        <property name="kb:documentRef">
           <type>d:text</type>
        </property>
     </properties>
  </aspect>
 </aspects>

kb-model-context.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Registration of new models -->
<bean id="extension.kb.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
    <property name="models">
        <list>
            <value>alfresco/extension/kb-model.xml</value>
        </list>
    </property>
</bean>

 <bean id="extension.kb.resourceBundle"   class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
   <property name="resourceBundles">
      <list>
         <value>alfresco.messages.knowledgebase</value>
      </list>
   </property>
</bean>
</beans>
alexwlchan
  • 5,699
  • 7
  • 38
  • 49
Arun M R Nair
  • 653
  • 7
  • 30
  • 1
    CHeck this out. https://forums.alfresco.com/forum/developer-discussions/alfresco-api/opencmis-adding-aspects-properties-03162014-2236 – mitpatoliya Dec 30 '14 at 10:58

1 Answers1

6

It's an old ticket, but I'll answer it.

As object type you'll need to fill in the prefix of the CMIS type.

  • D: for document
  • F: for folder
  • P: for Aspect

In CMIS 1.1 you can add (in your case an Aspect) as cmis:secondaryObjectTypeIds or SECONDARY_OBJECT_TYPE_IDS and prior to 1.1. as cmis:objectTypeId or OBJECT_TYPE_ID

Tahir Malik
  • 6,623
  • 15
  • 22
  • 1
    Unfortunately, these prefixes are Alfresco specific; for example, Apache Chemistry OpenCMIS (InMemory) does not need/want them (and even Alfresco only requires them in create statements, and rejects them in queries). Tools like OpenCMIS Workbench can still handle the differences, as they simply get a list of types, their ids and the query names from the server. But apparently custom client software should never hard code CMIS statements if those use custom types and should run against any CMIS repository. Software that has those statements hard coded will not work with Alfresco. Bummer. – Arjan Mar 14 '16 at 09:38