cancel
Showing results for 
Search instead for 
Did you mean: 

Problems importing content

hsjawanda
Champ in-the-making
Champ in-the-making
Hi,

I have defined my own content model that is complementary to Alfresco's content model.  Most of the content model works fine.  However, it seems that a cm:folder -like type that I have defined (called cms:folder) can only contain cm:content, not my own version of cm:content (called cms:asset).

("cm" being the namespace for Alfresco's content model, "cms" being my own (yeah, not very imaginative, I know Smiley Happy ))

This problem occurred when trying to bootstrap through ImporterBootstrap. I get an exception that basically says the entity contained within my cms:folder has to be of type cm:content.  Even when I try to derive my cms:asset from cm:content, I get the error message.  Temporarily, I've had to go back to using cm:content instead of cms:asset.

Could there be some hard-coded checking somewhere?  Any help would be highly appreciated.  Please do ask for clarification(s) if I've not been clear.  Thanks.

Here's my content model, wherein I've interspersed some comments for this post:



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

    <description>F1 CMS Content Model</description>
    <author>Alacre</author>
    <published>2005-10-05</published>
    <version>0.1</version>

    <imports>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
        <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
    </imports>

    <namespaces>
        <namespace uri="http://www.alacre.com/cms/content-model-1.0" prefix="cms"/>
    </namespaces>

    <types>
        <type name="cms:object">
            <title>Object</title>
            <parent>cm:cmobject</parent>
        </type>

        <type name="cms:container">
            <title>Container</title>
            <parent>cms:object</parent>
            <associations>
                <child-association name="cms:contains">
                    <source>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:cmobject</class> <!– This would've been cms:object –>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                    <duplicate>false</duplicate>
                </child-association>
            </associations>
        </type>

        <type name="cms:project">
            <title>Project</title>
            <parent>cms:container</parent>
        </type>

        <type name="cms:folder">
            <title>Folder</title>
            <parent>cms:container</parent>
        </type>

        <!–type name="cms:asset"> <!– My failed attempt to derive from cm:content. The derivation works, but not the import –>
            <title>Asset</title>
            <parent>cm:content</parent>
        </type–>
        <!– cms:asset is exactly analogous to cm:content, except that the auditable
             aspect has been made mandatory.
        <type name="cms:asset">  <!– The original definition –>
            <title>Asset</title>
            <parent>cms:object</parent>
            <properties>
                <property name="cm:contentUrl">
                    <type>d:text</type>
                    <mandatory>false</mandatory>
                    <index enabled="true">
                        <atomic>true</atomic>
                        <stored>false</stored>
                        <tokenised>true</tokenised>
                    </index>
                </property>
                <property name="cm:mimetype">
                    <type>d:text</type>
                    <mandatory>true</mandatory>
                </property>
                <property name="cm:encoding">
                    <type>d:text</type>
                    <mandatory>false</mandatory>
                </property>
                <property name="cm:size">
                    <type>d:long</type>
                    <mandatory>false</mandatory>
                </property>
            </properties>
            <mandatory-aspects>
                <aspect>cm:versionable</aspect>
            </mandatory-aspects>
        </type>
        –>

    </types>

</model>


6 REPLIES 6

davidc
Star Contributor
Star Contributor
There shouldn't be any hard-coding and the model you've defined seems valid from a glance.  Could you post the error stack and we can take a look.  In the mean-time, I'll have a go at importing your model to see if i can reproduce.

davidc
Star Contributor
Star Contributor
I guess from your description that you also have an xml file containing instances of cms:folder/cms:asset etc that you're trying to import into the repository during bootstrap.

Can you post that file too?  I've tested your model definition and it's fine.  So, there could be an issue in the data your attempting to import.

hsjawanda
Champ in-the-making
Champ in-the-making
Hi David (and others 🙂 ),

Before I forget to mention it, I am working with PR6 codebase.

I reproduced the error today and here's the stack trace (big 'un):


2005-11-03 14:30:40,351 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'importerBootstrap' defined in class path resource [alfresco/application-context.xml]: Initialization of bean failed; nested exception is org.alfresco.error.AlfrescoRuntimeException: Bootstrap failed
org.alfresco.error.AlfrescoRuntimeException: Bootstrap failed
   at org.alfresco.repo.importer.ImporterBootstrap.bootstrap(ImporterBootstrap.java:238)
   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:585)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:971)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:941)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:334)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:281)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:146)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:277)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:310)
   at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:133)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3669)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4104)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
   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:585)
   at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
   at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.apache.catalina.core.StandardContext.init(StandardContext.java:5005)
   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:585)
   at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
   at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:150)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:274)
   at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:91)
   at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:357)
   at org.jboss.web.WebModule.startModule(WebModule.java:68)
   at org.jboss.web.WebModule.startService(WebModule.java:46)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
   at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897)
   at $Proxy0.start(Unknown Source)
   at org.jboss.system.ServiceController.start(ServiceController.java:418)
   at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy28.start(Unknown Source)
   at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:394)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:956)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
   at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy8.deploy(Unknown Source)
   at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:325)
   at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:501)
   at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:204)
   at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:277)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:272)
   at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:222)
   at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:897)
   at $Proxy0.start(Unknown Source)
   at org.jboss.system.ServiceController.start(ServiceController.java:418)
   at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy4.start(Unknown Source)
   at org.jboss.deployment.SARDeployer.start(SARDeployer.java:273)
   at org.jboss.deployment.MainDeployer.start(MainDeployer.java:964)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:775)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:738)
   at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:722)
   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:585)
   at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
   at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
   at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:121)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:127)
   at org.jboss.mx.server.Invocation.invoke(Invocation.java:74)
   at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
   at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
   at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
   at $Proxy5.deploy(Unknown Source)
   at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:434)
   at org.jboss.system.server.ServerImpl.start(ServerImpl.java:315)
   at org.jboss.Main.boot(Main.java:195)
   at org.jboss.Main$1.run(Main.java:463)
   at java.lang.Thread.run(Thread.java:595)
Caused by: javax.transaction.RollbackException: The transaction was not committed - The node must be an instance of type content
   at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:269)
   at org.alfresco.repo.importer.ImporterBootstrap.bootstrap(ImporterBootstrap.java:230)
   … 135 more

The important part is:

The transaction was not committed - The node must be an instance of type content

I searched for the string "The node must be an instance of type content" and found it in RoutingContentService.java on lines 162 (getReader()), 200 (getWriter(NodeRef)) and 236 (getUpdatingWriter(NodeRef)). The exception is caused by the failure of
dictionary.isSubClass(QName, QName)
.

Investigation of M2ClassDefinition showed that in the end, it is the QName-s that are being compared.  Since my cms:asset type is declared in a different namespace, the QNames ContentModel.TYPE_CONTENT and cms:asset will never come out equal (or will they?).

What is the suggested work-around for this?

Here's the content model I used to produce the exception:

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

    <description>F1 CMS Content Model</description>
    <author>Alacre</author>
    <published>2005-10-05</published>
    <version>0.1</version>

    <imports>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
        <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
    </imports>

    <namespaces>
        <namespace uri="http://www.alacre.com/cms/content-model-1.0" prefix="cms"/>
    </namespaces>

    <types>
        <type name="cms:object">
            <title>Object</title>
            <parent>cm:cmobject</parent>
        </type>

        <type name="cms:container">
            <title>Container</title>
            <parent>cms:object</parent>
            <associations>
                <child-association name="cms:contains">
                    <source>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:cmobject</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                    <duplicate>false</duplicate>
                </child-association>
            </associations>
        </type>

        <type name="cms:project">
            <title>Project</title>
            <parent>cms:container</parent>
        </type>

        <type name="cms:folder">
            <title>Folder</title>
            <parent>cms:container</parent>
        </type>

        <type name="cms:asset">
            <title>Asset</title>
            <parent>cm:content</parent>
        </type>
        <!– cms:asset is exactly analogous to cm:content, except that the
             versionable aspect has also been made mandatory.
        <type name="cms:asset">
            <title>Asset</title>
            <parent>cms:object</parent>
            <properties>
                <property name="cm:contentUrl">
                    <type>d:text</type>
                    <mandatory>false</mandatory>
                    <index enabled="true">
                        <atomic>true</atomic>
                        <stored>false</stored>
                        <tokenised>true</tokenised>
                    </index>
                </property>
                <property name="cm:mimetype">
                    <type>d:text</type>
                    <mandatory>true</mandatory>
                </property>
                <property name="cm:encoding">
                    <type>d:text</type>
                    <mandatory>false</mandatory>
                </property>
                <property name="cm:size">
                    <type>d:long</type>
                    <mandatory>false</mandatory>
                </property>
            </properties>
            <mandatory-aspects>
                <aspect>cm:auditable</aspect>
                <aspect>cm:versionable</aspect>
            </mandatory-aspects>
        </type>
        –>

    </types>

</model>
I tried both definitions of cms:asset shown above, and both failed.

Here is my bootstrap data:

<view:view
    xmlns:view="http://www.alfresco.org/view/repository/1.0"
    xmlns:cm="http://www.alfresco.org/model/content/1.0"
    xmlns:cms="http://www.alacre.com/cms/content-model-1.0"
    xmlns:app="http://www.alfresco.org/model/application/1.0">

    <cm:folder>
        <cm:name>Project Root</cm:name>
        <cm:contains>
            <cms:project view:childName="cms:Project_1">
                <cm:name>Project 1</cm:name>
                <cms:contains>
                    <cms:folder>
                        <cm:name>Folder, Level 01, 03</cm:name>
                        <cms:contains>
                            <cms:asset>
                                <cm:name>Alfresco Tutorial.pdf</cm:name>
                                <cm:contentUrl>classpath:alfresco/bootstrap/Alfresco-Tutorial.pdf</cm:contentUrl>
                                <cm:mimetype>application/pdf</cm:mimetype>
                            </cms:asset>
                            <cms:folder>
                                <cm:name>Folder, Level 02, 10</cm:name>
                            </cms:folder>

                            <cms:folder>
                                <cm:name>Folder, Level 02, 02</cm:name>
                            </cms:folder>
                        </cms:contains>
                    </cms:folder>
                </cms:contains>
            </cms:project>

        </cm:contains>
    </cm:folder>

</view:view>

Seems like the only way I can use ImporterBootstrap to bootstrap my data is to derive my Asset type from cm:content inside the Alfresco namespace — this is not a very desirable solution.

Any suggestions?

davidc
Star Contributor
Star Contributor
Hi,

You're right, that's not very desirable.  To resolve the issue, we changed the way content is handled.  The change was made after PR6.

I would highly recommend upgrading to v1.0.  Instead of relying on a type called 'cm:content' we now support the notion of a Content data type.  Any property can now be assigned this data type, which means it can hold content of any length and be accessed via the Content Reader/Writer streaming interfaces.

Below are updated versions of your content model and content data files:

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

    <description>F1 CMS Content Model</description>
    <author>Alacre</author>
    <published>2005-10-05</published>
    <version>0.1</version>

    <imports>
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
        <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
    </imports>

    <namespaces>
        <namespace uri="http://www.alacre.com/cms/content-model-1.0" prefix="cms"/>
    </namespaces>

    <types>
        <type name="cms:object">
            <title>Object</title>
            <parent>cm:cmobject</parent>
        </type>

        <type name="cms:container">
            <title>Container</title>
            <parent>cms:object</parent>
            <associations>
                <child-association name="cms:contains">
                    <source>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cms:object</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                    <duplicate>false</duplicate>
                </child-association>
            </associations>
        </type>

        <type name="cms:project">
            <title>Project</title>
            <parent>cms:container</parent>
        </type>

        <type name="cms:folder">
            <title>Folder</title>
            <parent>cms:container</parent>
        </type>

        <!– cms:asset is exactly analogous to cm:content, except that the
             versionable aspect has also been made mandatory. –>
        <type name="cms:asset">
            <title>Asset</title>
            <parent>cms:object</parent>
            <properties>
                <property name="cms:content">
                    <type>d:content</type>
                    <mandatory>false</mandatory>
                    <index enabled="true">
                        <atomic>true</atomic>
                        <stored>false</stored>
                        <tokenised>true</tokenised>
                    </index>
                </property>
            </properties>
            <mandatory-aspects>
                <aspect>cm:auditable</aspect>
                <aspect>cm:versionable</aspect>
            </mandatory-aspects>
        </type>

    </types>

</model>

Notice that the property cms:content on cms:asset is of type d:content.

<view:view
    xmlns:view="http://www.alfresco.org/view/repository/1.0"
    xmlns:cm="http://www.alfresco.org/model/content/1.0"
    xmlns:cms="http://www.alacre.com/cms/content-model-1.0"
    xmlns:app="http://www.alfresco.org/model/application/1.0">

    <cm:folder>
        <cm:name>Project Root</cm:name>
        <cm:contains>
            <cms:project view:childName="cms:Project_1">
                <cm:name>Project 1</cm:name>
                <cms:contains>
                    <cms:folder>
                        <cm:name>Folder, Level 01, 03</cm:name>
                        <cms:contains>
                            <cms:asset>
                                <cm:name>Alfresco Tutorial.pdf</cm:name>
                              <cms:content>contentUrl=classpath:alfresco/bootstrap/Alfresco-Tutorial.pdf|mimetype=application/pdf|size=|encoding=</cms:content>
                            </cms:asset>
                            <cms:folder>
                                <cm:name>Folder, Level 02, 10</cm:name>
                            </cms:folder>
                            <cms:folder>
                                <cm:name>Folder, Level 02, 02</cm:name>
                            </cms:folder>
                        </cms:contains>
                    </cms:folder>
                </cms:contains>
            </cms:project>
        </cm:contains>
    </cm:folder>

</view:view>

Notice that the cm:content value has changed, and that there are no longer seperate properties for mimetype etc.

I tested the above with v1.0 and they went into the repository.  You won't be able to see those items through the Alfresco Web Client because its looking for items of type cm:folder, cm:content etc.  However, there is an administration tool (added in v1.0) for browsing the contents of your repository available at http://[yourhost]:8080/alfresco/faces/jsp/admin/store-browser.jsp which will let you see your items for testing purposes.

Hope that helps.

hsjawanda
Champ in-the-making
Champ in-the-making
Hi David,

Thanks for your help and advice.  I upgraded most of our code to use Alfresco v1.0 today.  This includes using our model (and cms:asset type) and being able to bootstrap data that is in accordance with our data model.  However, an issue did come up along the way, and I have some questions too.

If I put the loading-up configuration for my data model in extension.dictionaryBootstrap, the importer would throw an exception saying that my content model's URI had not been published with the dictionary service.  Moving my content model to dictionaryBootstrap (the one in application-context.xml) solved my problem.  Seems like the data models listed under extension.dictionaryBootstrap are not getting imported (at least mine wasn't).  Is there some other configuration that I missed?

Since content is now a property type, what happens when one does nodeService.getProperties(NodeRef)?  Does all of the content end up loaded into memory?  This could easily be in 10s of MBs (or more).  Exactly what "Serializable" object is returned in the Map for a property of type d:content?

I noticed in the Data Dictionary Guide wiki that d:content corresponds to String.  Does this mean all of the data corresponding to d:content ends up being loaded as a single String?  Somehow I doubt that.

I was thinking that I would probably need to determine the type of the property, and if it is of type d:content, I would have to get a ContentReader and use that to both get at the bytes representing the content and its properties like mimetype, size, date created etc.

How about the handling of non-d:content properties?  Has that changed?  Or is it ok (other than null-checking etc.) to do something like:
nodeService.getProperty(nodeRef, propertyQName).toString()

for dumping properties on a (JSP) page?

davidc
Star Contributor
Star Contributor
Hi,

If I put the loading-up configuration for my data model in extension.dictionaryBootstrap, the importer would throw an exception saying that my content model's URI had not been published with the dictionary service. Moving my content model to dictionaryBootstrap (the one in application-context.xml) solved my problem. Seems like the data models listed under extension.dictionaryBootstrap are not getting imported (at least mine wasn't). Is there some other configuration that I missed?

Actually, there's a bug in our application-context.xml.  The "dictionaryService" bean should depend on "extension.dictionaryBootstrap".  This will be fixed in the next release, but in the mean-time if you change:

depends-on="dictionaryBootstrap"
to
depends-on="extension.dictionaryBootstrap"
for the "dictionaryService" bean you can leave your model in extension-context.xml.

Since content is now a property type, what happens when one does nodeService.getProperties(NodeRef)? Does all of the content end up loaded into memory? This could easily be in 10s of MBs (or more). Exactly what "Serializable" object is returned in the Map for a property of type d:content?

No, the content is not loaded into memory 🙂 The property is represented as an org.alfresco.service.cmr.repository.ContentData.  This class holds info about the content, but not the content itself e.g. url within repository content store, mimetype, size…

I noticed in the Data Dictionary Guide wiki that d:content corresponds to String. Does this mean all of the data corresponding to d:content ends up being loaded as a single String? Somehow I doubt that.


The WIKI was out-of-date, I've updated it now to reflect the ContentData class described above.

I was thinking that I would probably need to determine the type of the property, and if it is of type d:content, I would have to get a ContentReader and use that to both get at the bytes representing the content and its properties like mimetype, size, date created etc.

Yes, that's right.  We have some general repository components such as the Indexer, Export/Import, Copy etc that do exactly that.

How about the handling of non-d:content properties? Has that changed? Or is it ok (other than null-checking etc.) to do something like…

Yes, that's perfectly ok.

Thanks for persevering with our product and alerting us to issues - thankfully, they were very easy to fix 🙂
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.