cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a multivalue property of custom aspect

andea
Champ in-the-making
Champ in-the-making
I'm working with Alfresco CE 3.3 and i've just defined a custom aspect with a set of multivalue properties.

I need to set this value with an array of String.

This is my code:
<!– Generic document type –>
      <type name="cp:documento">
         <title>Documento</title>
         <parent>cm:content</parent>
         <mandatory-aspects>
            <aspect>cm:countable</aspect>
            <aspect>cp:datiprotocollo</aspect>
         </mandatory-aspects>
      </type>

      <!– Generic document type –>
      <type name="cp:protocollo">
         <title>Protocollo</title>
         <parent>cp:documento</parent>
      </type>



                               <property name="cp:destinatari">
               <title>Destinatari(o)</title>
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>true</multiple>
            </property>
         </properties>
      </aspect>

   </aspects>


I've defined my custom content wizard to create my content type. This a snippet of method "finishImpl()" code:

    NodeService nSer = this.getNodeService();
    nSer.setProperty(this.createdNode, Protocollo.PROP_MITTENTE, mittente);
    nSer.setProperty(this.createdNode, Protocollo.PROP_DESTINATARI, destinatariArray);

where "destinataryArray" is a String[] type.

When i try to set the property "destinatari" with the object NodeService i've the following error:

User:admin ERROR [ui.common.Utils] Failed to create content due to error: The property value is not compatible with the type defined for the property: 
   property: Name: {http://www.xxx.it/model/content/1.0}destinatari
Title: Destinatari(o)
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}text
ContainerClass Name: {http://www.xxx.it/model/content/1.0}datiprotocollo
isMultiValued: true
isMandatory: true
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE

   value: [Ljava.lang.String;@44a45d
   value type: class [Ljava.lang.String;
org.alfresco.service.cmr.repository.datatype.TypeConversionException: The property value is not compatible with the type defined for the property:
   property: Name: {http://www.xxx.it/model/content/1.0}destinatari
Title: Destinatari(o)
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}text
ContainerClass Name: {http://www.xxx.it/model/content/1.0}datiprotocollo
isMultiValued: true
isMandatory: true
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE

   value: [Ljava.lang.String;@44a45d
   value type: class [Ljava.lang.String;
   at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.makeNodePropertyValue(HibernateNodeDaoServiceImpl.java:5066)
   at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.addValueToPersistedProperties(HibernateNodeDaoServiceImpl.java:5021)
   at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.addValueToPersistedProperties(HibernateNodeDaoServiceImpl.java:4901)
   at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.addNodePropertyImpl(HibernateNodeDaoServiceImpl.java:1471)
   at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.addNodeProperty(HibernateNodeDaoServiceImpl.java:1510)
   at sun.reflect.GeneratedMethodAccessor347.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:616)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.transaction.TransactionalDaoInterceptor.invoke(TransactionalDaoInterceptor.java:62)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.invoke(DirtySessionMethodInterceptor.java:413)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invokeInternal(SingleEntryTransactionResourceInterceptor.java:157)
   at org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invoke(SingleEntryTransactionResourceInterceptor.java:132)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy8.addNodeProperty(Unknown Source)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.setPropertyImpl(DbNodeServiceImpl.java:1390)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.setProperty(DbNodeServiceImpl.java:1354)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:616)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:104)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy10.setProperty(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:616)
   at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:215)
   at $Proxy11.setProperty(Unknown Source)
   at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:249)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:260)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:260)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy10.setProperty(Unknown Source)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:616)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:43)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:135)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy10.setProperty(Unknown Source)
   at org.alfresco.extension.wizard.CreateProtocolloWizard.finishImpl(CreateProtocolloWizard.java:313)
   at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:118)
   at org.alfresco.web.bean.dialog.BaseDialogBean$1.execute(BaseDialogBean.java:115)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:321)
   at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:124)
   at org.alfresco.web.bean.content.CreateContentWizard.finish(CreateContentWizard.java:115)
   at org.alfresco.web.bean.wizard.WizardManager.finish(WizardManager.java:593)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:616)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
   at javax.faces.component.UICommand.broadcast(UICommand.java:109)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:104)
   at sun.reflect.GeneratedMethodAccessor488.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:616)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy203.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:68)
   at sun.reflect.GeneratedMethodAccessor488.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:616)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy203.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:636)
Caused by: org.alfresco.service.cmr.repository.datatype.TypeConversionException: There is no conversion registered for the value:
   value class: [Ljava.lang.String;
   to class: java.lang.String
   value: [Ljava.lang.String;@44a45d
   at org.alfresco.service.cmr.repository.datatype.TypeConverter.convert(TypeConverter.java:107)
   at org.alfresco.repo.domain.NodePropertyValue$ValueType$7.convert(NodePropertyValue.java:202)
   at org.alfresco.repo.domain.NodePropertyValue.<init>(NodePropertyValue.java:746)
   at org.alfresco.repo.node.db.hibernate.HibernateNodeDaoServiceImpl.makeNodePropertyValue(HibernateNodeDaoServiceImpl.java:5060)
   … 117 more

Any idea?
Tnx
3 REPLIES 3

rbkprod
Champ in-the-making
Champ in-the-making
This is a shot in the dark - but would it help if you add

<many>true</many>
at the destinatari properties ? Or is that the same as the
 <multiple>true</multiple> 
you have there?

andea
Champ in-the-making
Champ in-the-making
This is a shot in the dark - but would it help if you add

<many>true</many>
at the destinatari properties ? Or is that the same as the
 <multiple>true</multiple> 
you have there?

Tnx for reply.
Yes, i've the tag <multiple> in properties declarations.
            <property name="cp:destinatari">
               <title>Destinatari(o)</title>
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>true</multiple>
            </property>

conte73
Champ in-the-making
Champ in-the-making
Hi!
From your code i guess you are trying to add an array. I succeeded adding an ArrayList instead.


NodeService nSer = this.getNodeService();
ArrayList arl=new ArrayList();
arl.addAll(Arrays.asList(new String[] { "1", "2", "3" }));
map.put(Protocollo.PROP_DESTINATARI, arl);
map.put(Protocollo.PROP_MITTENTE, mittente);
nSer.addProperties(this.createdNode, map);

Ok, i used "addProperties" but i think you can use "setProperty" too.
Hope this will help.
Gabriele