cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Custom Content Model for a XML file

carolanna
Champ in-the-making
Champ in-the-making
Hi. Am using Alfresco community version 3.2r.
I want to create a custom content model for the below xml file.

<?xml version="1.0" encoding="UTF-8"?>
<SUBMISSION SUBMISSIONKEY="2EE">
    <STARTED>1293168061201</STARTED>
    <FINISHED>1293168061203</FINISHED>
    <PROPERTIES KEY="F9">
                <PROPERTY>
                    <PROPERTYKEY>ADDRESS</PROPERTYKEY>
                    <PROPERTYVALUE>202 HARTNELL PL</PROPERTYVALUE>
                </PROPERTY>
                <PROPERTY>
                    <PROPERTYKEY>ZIP</PROPERTYKEY>
                    <PROPERTYVALUE>6753</PROPERTYVALUE>
                </PROPERTY>
    </PROPERTIES>
</SUBMISSION>

am able to upload xml files into alfresco using java application.while retriving i want to retrieve based on particular parameters such as address,zip,started number etc.

i have created a constants java file for creating new QNames
import org.alfresco.service.namespace.QName;
public class ExtractorConstants {

   // public static final String NAMESPACE_CONTENT_MODEL = "http://www.alfresco.org/model/content/1.0";
      public static final QName DATE_STARTED = QName.createQName("", "STARTED");
      public static final QName DATE_FINISHED = QName.createQName("", "FINISHED");
      public static final QName ORDER_NUMBER = QName.createQName("", "SUBMISSIONKEY");
      public static final QName ADDRESS=QName.createQName("", "ADDRESS");
      public static final QName ZIP=QName.createQName("", "ZIP");
      public static final QName FIRST_NAME=QName.createQName("", "ADRFNAME");
      public static final QName LAST_NAME=QName.createQName("", "ADRLNAME");

}
 

Normally if am using default alfresco content model we specify

public static final String   PROP_NAME = createQNameString(NAMESPACE_CONTENT_MODEL, "name");

but what in case of custom content model.

Anyone plz help me with this.
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
You would use your model rather than NAMESPACE_CONTENT_MODEL.

Typically you would define a class to contain the "constants" of you namespace/type/properties.  Look at ContentModel.xml as an example.

carolanna
Champ in-the-making
Champ in-the-making
Hi..
i created a model customModel.xml in c:\Alfresco\tomcat\shared\classes\alfresco\extension.
Then in same directory i renamed custom-model-context.sample.xml to custom-model-context.xml.
When i start the server am getting the below error.Please help me.   
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\custom-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 04030001 Could not import bootstrap model alfresco/extension/customModel.xml
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 04030001 Could not import bootstrap model alfresco/extension/customModel.xml
        at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:151)
        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:592)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)