cancel
Showing results for 
Search instead for 
Did you mean: 

Content type with multiple d:content properties

aspa
Champ in-the-making
Champ in-the-making
Hi,

I'm trying to define a content type that would allow multiple items of d:content to be attached.
I created a custom type based on cm:content with the following definition

    <type name="my:content">
      <parent>cm:cmobject</parent>
      <properties>
        <property name="my:content">
          <type>d:content</type>
          <multiple>true</multiple>
        </property>
      </properties>
    </type>
but model validation fails if I set multiple=true.

It seems that Alfresco doesn't allow properties of this type to be multivalued.
I would need to attach multiple files to a content item.

What would be the best way to achieve this?
Should I model the compound content type by extending cm:content and using association?
Or extend cm:folder and use containment?
4 REPLIES 4

derek
Star Contributor
Star Contributor
Hi,
Could you post the exception log, please.  I don't remember adding that restriction in - it could be a regression or side-effect of some other change.  But let's look at the failure and I can advise further.
Regards

aspa
Champ in-the-making
Champ in-the-making
Hi,

Here's what org.alfresco.repo.dictionary.TestModel says:


validate-model:
     [java] Working directory ignored when same JVM is used.
     [java] Testing dictionary model definitions…
     [java]  alfresco/model/dictionaryModel.xml
     [java]  alfresco/model/systemModel.xml
     [java]  org/alfresco/repo/security/authentication/userModel.xml
     [java]  alfresco/model/contentModel.xml
     [java]  alfresco/model/wcmModel.xml
     [java]  alfresco/model/applicationModel.xml
     [java]  alfresco/model/bpmModel.xml
     [java]  config/alfresco/module/foo.bar.intranet.cm/foobarIntranetModel.xml
     [java] Found an invalid model…
     [java] Could not import bootstrap model config/alfresco/module/foo.bar.intranet.cm/foobarIntranetModel.xml
     [java] Failed to compile model my::foobarmodel
     [java] d_dictionary.property.err.single_valued_content

org.alfresco.repo.dictionary.M2PropertyDefinition seems to emit a DictionaryException with the above key if a multivalued property of type d:content is defined.

After installing the model, Alfresco also failed to start and issued the following error:


SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org_alfresco_module_foobarIntranet_dictionaryBootstrap' defined in file [D:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\module\foo.bar.intranet.cm\module-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap model alfresco/module/foo.bar.intranet.cm/foobarIntranetModel.xml
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap model alfresco/module/foo.bar.intranet.cm/foobarIntranetModel.xml
        at org.alfresco.repo.dictionary.DictionaryBootstrap.initDictionary(DictionaryBootstrap.java:147)
        at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:108)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1240)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean

derek
Star Contributor
Star Contributor
Hi,

That restriction should no longer be necessary (since 3.x) - I'll look at changing it.  You could facilitate by grabbing the source and commenting out the offending code in projects/repository/source/java/org/alfresco/repo/dictionary/M2PropertyDefinition:

        // ensure content properties are not multi-valued
        if (propertyTypeName.equals(DataTypeDefinition.CONTENT) && isMultiValued())
        {
            throw new DictionaryException("d_dictionary.property.err.single_valued_content");
        }
Let us know if any nasty issues arise.

Most implementations (that I am aware of) use an aspect with one-to-many child associations to do the containment.  This works well and allows more metadata to be associated with the stored content snippets i.e. each subdocument is treated as first class content.  However, make the change and let us know if any nasties appear.

Regards

jamen
Confirmed Champ
Confirmed Champ
Hi Derek,

I'm just having a look at the 3.3.1 E code base and it appears that no changes have been made to stop this single value constraint for d:content properties.  I can override this so this isn't an issue.

But doesn't a child association inhibit your ability to full text search for the parent item based on the child content item?  Lucene doesn't really support queries for a parent based on the contents of a child without doing a two query inspection.

Thanks
Jamen