cancel
Showing results for 
Search instead for 
Did you mean: 

Custom type and attributes

nicolasb
Champ in-the-making
Champ in-the-making
Hi,

New to Alfresco I'm trying to create a custom type with some custom attributes.
I can create some custom documents using the UI and now I am trying to create some using the following code :


                ChildAssociationRef assocRef = nodeService.createNode(
                        noderefdmcl,
                        ContentModel.ASSOC_CHILDREN,
                        QName.createQName(NamespaceService.ALFRESCO_URI,
                                          QName.createValidLocalName(
                                                  filename)),
                        QName.createQName("{custom.model}ren_dmodule"),
                        nodeProperties);

It does work fine.
Unfortunately, I can't read or write custom properties :

nodeService.setProperty(assocRef.getChildRef(), QName.createQName("{custom.model}modelic"), "toto");
or
System.out.println(nodeService.getProperty(assocRef.getChildRef(), QName.createQName("{custom.model}modelic")));

CustomModel.xml :
   <namespaces>
      <namespace uri="custom.model" prefix="es"/>
   </namespaces>
<types>  
<type name="es:ren_dmodule">
<title>data module</title>
<parent>cm:content</parent>
<properties>
  <property name="es:modelic">
       <title>modelic</title>
       <type>d:text</type>
       <mandatory>false</mandatory>
       <index enabled="true">
     <atomic>true</atomic>
     <stored>false</stored>
     <tokenised>true</tokenised>
       </index>
  </property>



What is wrong ?


Regards,


Nicolas B.
5 REPLIES 5

davidc
Star Contributor
Star Contributor
Hi Nicolas,

Could you let us know the error you're getting?

nicolasb
Champ in-the-making
Champ in-the-making
Hi,

Restarting Alfresco solved my problem, but I still have a question Smiley Happy

I am using JBuilder and running my class from it. I get no error, but the content of the new property is null.
I can't see the created object in Alfresco UI too.

I have to restart Alfresco to see the new object/attribute value in the web UI.

I can't anderstand this lag.

Regards,


Nicolas

davidc
Star Contributor
Star Contributor
That's due to the caching in the Alfresco server.  The running server will have no idea that your local test client has modified the persistent store state.

If you wish to run a remote client against the server, you either have to use the Alfresco web service interfaces, JCR-RMI (see http://www.alfresco.org/forums/viewtopic.php?t=488) or provide your own remote facade onto our services.

Or for testing/experimental purposes you can switch off the level 2 cache in the server by setting (in alfresco/domain/hibernate-cfg.properties):

hibernate.cache.use_second_level_cache=true

to

hibernate.cache.use_second_level_cache=false

This will then allow you to refresh the web client without re-starting - but of course it may be slower.

nicolasb
Champ in-the-making
Champ in-the-making
ok,

thanks a lot.

greglenain
Champ in-the-making
Champ in-the-making
Hi,

Is there a way to force the Alfresco cache to refresh after inserting a big amount of data?

Thanks.