cancel
Showing results for 
Search instead for 
Did you mean: 

opencmis - addaspect - Alfresco 4.2

luigi
Champ in-the-making
Champ in-the-making
Hello,

I trying write an application using the alfresco opencmis plugin in Alfresco 4.2 Community Ed (Bitnami VM).
I just created a custom model with custom aspect.
those are my steps:
- Rename /…/shared/classes/extension/custom-model-context.xml.sample to custom-model-context.xml and customModel.xml.sample to customModel.xml
This is my custom aspect in customModel.xml:


<aspects>
<aspect name="custom:ModuloDetails">
<title>Document Dettaglio Moduloies>
<property name="custom:CodProtocollo">
<title>Codice Modulo</title>
<type>d:text</type>
<protected>false</protected>
<mandatory>true</mandatory>
<multiple>false</multiple>
</property>
<property name="custom:CodModulo">
<title>Codice Modulo</title>
<type>d:text</type>
</property>
</properties>
</aspect>
</aspects>



- Rename  web-client-config-custom.xml.sample web-client-config-custom.xml
this is my code added


<config evaluator="string-compare" condition="Action Wizards">
<aspects>
<aspect name="custom:ModuloDetails"/>
</aspects>
</config>

<config evaluator="aspect-name" condition="custom:ModuloDetails">
<property-sheet>
<show-property name="custom:CodProtocollo"/>
<show-property name="custom:CodModulo"/>
</property-sheet>
</config>



Problems:
1. no additional properties visible in Alfresco
2. if I add aspect programmatically


AlfrescoDocument alfDoc = (AlfrescoDocument) doc;
alfDoc.addAspect("P:custom:ModuloDetails");


I have got this error
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Bad Request

Any help appreciated.

Thanks
7 REPLIES 7

marco_altieri
Star Contributor
Star Contributor
Hi,

why is there a "P:" before the name of the aspect ?

Marco

luigi
Champ in-the-making
Champ in-the-making
Thanks for the reply Marco,

my code derive from this link
<a href='http://docs.alfresco.com/4.1/index.jsp?topic=%2Fcom.alfresco.enterprise.doc%2Fconcepts%2Fopencmis-ex...'>docs.alfresco.com</a>

anyway the result is the same with P, D or without character …

<strong>
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: Bad Request
</strong>

kaynezhang
World-Class Innovator
World-Class Innovator

<aspects>

<aspect name="custom:ModuloDetails">

<title>Document Dettaglio Moduloies>

<property name="custom:CodProtocollo">

<title>Codice Modulo</title>

<type>d:text</type>

<protected>false</protected>

<mandatory>true</mandatory>

<multiple>false</multiple>

</property>

<property name="custom:CodModulo">

<title>Codice Modulo</title>

<type>d:text</type>

</property>

</properties>

</aspect>

</aspects>

Since your model defination is illegal,it can't be registed correctly.
So of cause you can't add this apect to a node correctly.

luigi
Champ in-the-making
Champ in-the-making
Ki kynezhanfor,

if you mean "illegal" for this code

<title>Document Dettaglio Moduloies>


ok, is a my error but in this post.
In customModel.xml is ok, :

<title>Dettaglio Modulo</title>


Or you mean "illegal" for other ?
Thanks.

kaynezhang
World-Class Innovator
World-Class Innovator
1. Your xml dose not have model element,model element is root element
2..Your xml dose not have imports element and namespaces element.
3. Property should be subelement of properties

luigi
Champ in-the-making
Champ in-the-making
kaynezhang, my code was an extract but Thanks anyway !

After other test, I have some update, follow this way:
rename of example file in
$TOMCAT_HOME/shared/classes/extension

customModel.xml

<?xml version="1.0" encoding="UTF-8"?>



<!– Custom Model –>



<!– Note: This model is pre-configured to load at startup of the Repository.  So, all custom –>

<!–       types and aspects added here will automatically be registered –>



<model name="sc:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">



   <!– Optional meta-data about the model –>  

   <description>Custom Model</description>

   <author></author>

   <version>1.0</version>



   <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"/>

   </imports>



   <!– Introduction of new namespaces defined by this model –>

   <!– NOTE: The following namespace custom.model should be changed to reflect your own namespace –>

   <namespaces>

      <!–namespace uri="custom.model" prefix="custom"/–>

      <namespace uri="http://www.someco.com/model/content/1.0" prefix="sc" />



   </namespaces>





<types>

<!– Enterprise-wide generic document type –>

<type name="sc:doc">

<title>Someco Document</title>

<parent>cm:content</parent>

<associations>

<association name="sc:relatedDocuments">

<title>Related Documents</title>

<source>

<mandatory>false</mandatory>

<many>true</many>

</source>

<target>

<class>sc:doc</class>

<mandatory>false</mandatory>

<many>true</many> </target>

</association>

</associations>

<mandatory-aspects>

<aspect>cm:generalclassifiable</aspect>

</mandatory-aspects>

</type>

<type name="sc:whitepaper">

<title>Someco Whitepaper</title>

<parent>sc:doc</parent>

</type>

</types>

<aspects>

<aspect name="sc:webable">

<title>Someco Webable</title>

<properties>

<property name="sc:published">

<type>d:date</type>

</property>

<property name="sc:isActive">

<type>d:boolean</type>

<default>false</default>

</property>

</properties>

</aspect>

<aspect name="sc:productRelated">

<title>Someco Product Metadata</title>

<properties>

<property name="sc:product">

<type>d:text</type>

<mandatory>true</mandatory>

</property>

<property name="sc:version">

<type>d:text</type>

<mandatory>true</mandatory>

</property>

</properties>

</aspect>

</aspects>



</model>


and
custom-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.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">

        <property name="models">

            <list>

                <value>alfresco/extension/customModel.xml</value>

            </list>

        </property>

    </bean>



</beans>


and added some code in
$TOMCAT_HOME/shared/classes/alfresco/web-extension

share-config-custom.xml

<alfresco-config>
<!– Document Library config section –>

   <config evaluator="string-compare" condition="DocumentLibrary">

      <aspects>

            <!– Aspects that a user can see –>

            <visible>

            <aspect name="sc:webable" />

            <aspect name="sc:productRelated" />

            </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>

      <types>

            <type name="cm:content">

                  <subtype name="sc:doc" />

                  <subtype name="sc:whitepaper" />

            </type>

                  <type name="sc:doc">

                  <subtype name="sc:whitepaper" />

            </type>

      </types>

   </config>


</alfresco-config>


At the end, i can see new aspect in share manage Aspect (see uno.png image) but when save i have an error message (see due.png image) "Could not update aspects".

Any help would be apprecciated.
Thank you in adavance

Luigi

luigi
Champ in-the-making
Champ in-the-making
It was a problem of Bitnami version …. with standard community pakage is ok !
Thanks!
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.