cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Content Model Tutorial

jpotts
World-Class Innovator
World-Class Innovator
If you are new to creating custom content models and configuring the Explorer and Share user interfaces to show the types, aspects, properties, and associations from your custom content model, please read the <a href="http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html">Custom Content Model tutorial</a> available at ecmarchitect.com. The tutorial includes how to create a custom model, how to configure Alfresco Share, and how to work with the CMIS API to perform CRUD functions against the repository using your custom content model, including several CMIS Query Language examples.

The tutorial was recently (January, 2014) updated to assume you are using the Alfresco Maven SDK and AMPs rather than the old Ant-based SDK to produce ZIPs.

Jeff
29 REPLIES 29

alfresco-jan
Champ in-the-making
Champ in-the-making
Hi Jeff,
I followed your updated tutorial with Alfresco 4.2.f. I could not manage to use maven for compiling / deploying alfresco. I raised this issue in the google group: http://code.google.com/p/maven-alfresco-archetypes/issues/detail?id=194&sort=-id

Anyway (as a workaround), I extracted the information for this tutorial with a installed Alfresco 4.2f and could use the information for a customised document type (in the folder  tomcat7/shared/ …)

I have successfully extended the alfresco repository for a custom document type with custom aspects.
I can access the model changes via the alfresco api (cmis).
The next step is to view the changes in the alfreso share client.

I copied the shared/classes/alfresco/web-extension/share-config-custom.xml.sample

and extended this file as seen in the vimdiff screenshot (attached)

From the tutorial steps, I am stuck at Part 2 (Configuring Alfresco Share), Step 3 test / see your changes.

I can add a new rule: specify content type -> new custom content type (in my case kivitendo:doc)

I can also see my custom aspects, but if I try to add this aspect (even if I changed the type to my custom doc model), I get the error: "Could not change aspect".

I am grateful for any hints …

thx,
Jan

rjohnson
Star Contributor
Star Contributor
You should find a lengthy error in alfresco.log.

That should give you a good pointer to your problem.

The only thing which appears in the log file (acces..log), are two successful posts and after that normal gets (all with 200 return-code)
POST /share/proxy/alfresco/slingshot/doclib/action/aspects/node/workspace/SpacesStore/89a2a125-c738-4295-a2a7-5c7b2474bbda HTTP/1.1" 200 355
127.0.0.1 - -
[10/Nov/2014:16:55:29 +0100] "POST /alfresco/s/slingshot/doclib/action/aspects/node/workspace/SpacesStore/89a2a125-c738-4295-a2a7-5c7b2474bbda?alf_ticket=TICKET_fa2fe196b4f5ee498f580c12248d8603ed25aa9a HTTP/1.1" 200 355

Probably the error is thrown via ajax in my browser client?

jpotts
World-Class Innovator
World-Class Innovator
That looks like something from the Share log rather than the underlying catalina.out. There should be an exception being thrown or something that hints at why the aspect couldn't be set.

Jeff

mvicidomini
Champ in-the-making
Champ in-the-making
Hello All I would like to create a custom model for invoices. As I am a beginner I'm trying to use some tutorial, but after having spent hours I cannot managed to setup my custom model/type.
When I try to change the type of a document I have this error in the log file :

Namespace prefix my is not mapped to a namespace URI.

Could someone help me ?

I have attached my customModel.xml and custom-model-context.xml files

Thanks in advance

mrogers
Star Contributor
Star Contributor
Can't see any error in what you have posted.

How have you deployed this code and was there any more of the error message?

mvicidomini
Champ in-the-making
Champ in-the-making
I have posted my xml files only.
Pleased find below an example of the log.
Has I have a test instance of Alfresco, I have just modified the xml and the restart the app.

2015-01-22 16:16:41,275  ERROR [extensions.webscripts.AbstractRuntime] [ajp-bio-8009-exec-12] Exception from executeScript - redirecting to status template error: 00220000 Wrapped Exception (with status template): 00220006 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js': Namespace prefix ft is not mapped to a namespace URI
org.springframework.extensions.webscripts.WebScriptException: 00220000 Wrapped Exception (with status template): 00220006 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js': Namespace prefix ft is not mapped to a namespace URI
   at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1126)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:171)
   at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:470)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:454)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:532)
   at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:600)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:380)
   at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:261)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)
   at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
   at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
   at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
   at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
   at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
   at java.lang.Thread.run(Thread.java:745)
Caused by: org.alfresco.scripts.ScriptException: 00220006 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js': Namespace prefix ft is not mapped to a namespace URI
   at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:204)
   at org.alfresco.repo.processor.ScriptServiceImpl.execute(ScriptServiceImpl.java:212)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:174)
   at org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
   at org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1364)
   at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
   … 33 more
Caused by: org.alfresco.service.namespace.NamespaceException: Namespace prefix ft is not mapped to a namespace URI
   at org.alfresco.service.namespace.QName.createQName(QName.java:102)
   at org.alfresco.service.namespace.QName.createQName(QName.java:124)
   at org.alfresco.repo.jscript.ScriptNode.createQName(ScriptNode.java:3471)
   at org.alfresco.repo.jscript.ScriptNode.specializeType(ScriptNode.java:1718)
   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:606)
   at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
   at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
   at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:32)
   at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_slingshot_documentlibrary_type_post_json_js_16._c_main_1(classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js:24)
   at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_slingshot_documentlibrary_type_post_json_js_16.call(classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js)
   at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:74)
   at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_slingshot_documentlibrary_type_post_json_js_16._c_script_0(classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js:33)
   at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_slingshot_documentlibrary_type_post_json_js_16.call(classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
   at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_slingshot_documentlibrary_type_post_json_js_16.call(classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js)
   at org.mozilla.javascript.gen.classpath__alfresco_templates_webscripts_org_alfresco_slingshot_documentlibrary_type_post_json_js_16.exec(classpath*:alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/type.post.json.js)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:502)
   at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:200)
   … 38 more

jpotts
World-Class Innovator
World-Class Innovator
The error complains about a namespace prefix called "ft" but your namespace abbreviation according to your content model XML is "my". You need to make sure that all of the namespace prefixes you are using are declared in your content model XML.

Jeff

mvicidomini
Champ in-the-making
Champ in-the-making
Sorry here is the file but I still have the same issue.

<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="ft:modelfactures" xmlns="http://www.alfresco.org/model/dictionary/1.0">
    <!– Optional meta-data about the model –>
    <description>Someco Model</description>
    <author>Jeff Potts</author>
    <version>1.0</version>

    <!– Imports are required to allow references to definitions in other models –>
    <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 –>
    <namespaces>
        <namespace uri="http://www.alfresco.org/model/factures/1.0" prefix="ft" />
    </namespaces>
    <types>
     <!– Definition of new Content Type: Standard Operating Procedure –>
      <type name="ft:facture">
         <title>Factures</title>
         <parent>cm:content</parent>
         <properties>
            <property name="ftSmiley TongueublishedDate">
               <type>d:datetime</type>
            </property>
            <property name="ft:authorisedBy">
               <type>d:text</type>
            </property>
         </properties>
         <associations>
            <association name="ft:signOff">
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>
            <child-association name="ftSmiley TonguerocessSteps">
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
         </child-association>           
         </associations>
      </type>
     
    </types>
   
    <aspects>
      <!– Definition of new Content Aspect: Image Classification –>
      <aspect name="ft:imageClassification">
         <title>Image Classfication</title>
         <properties>
            <property name="ft:width">
               <type>d:int</type>
            </property>
            <property name="ft:height">
               <type>d:int</type>
            </property>
            <property name="ft:resolution">
               <type>d:int</type>
            </property>
         </properties>
      </aspect>
     
   </aspects>
   </model>

mvicidomini
Champ in-the-making
Champ in-the-making
Sorry here it is