cancel
Showing results for 
Search instead for 
Did you mean: 

Content Aspect with Constraint for a List-Box

schneika
Champ in-the-making
Champ in-the-making
Alfresco V2.1.0 CE on Linux. I need a aspect with list box. This is my exampleModel.xml:

<?xml version="1.0" encoding="UTF-8"?>

<model name="my:mynewmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Example custom Model</description>
   <author></author>
   <version>1.0</version>

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

   <namespaces>
      <namespace uri="my.new.model" prefix="my"/>
   </namespaces>

   <contraints>    <!– This is the typo, an error –>

     <!– Definition of new constraints: Fachbereich –>
     <constraint name="my:Fachbereich" type="LIST">
       <parameter name="allowedValues">
          <list>
             <value>AM</value>
             <value>PrM</value>
             <value>KB</value>
             <value>VAD</value>
             <value>VID</value>
          </list>
       </parameter>
      </constraint>
 
   </constraints>


   <types>
  
      <!– Definition of new Content Type: Standard Operating Procedure –>
      <type name="my:sop">
         <title>Standard Operating Procedure</title>
         <parent>cm:content</parent>
         <properties>
            <property name="my:publishedDate">
               <type>d:datetime</type>
            </property>
            <property name="my:authorisedBy">
               <type>d:text</type>
            </property>
         </properties>
         <associations>
            <association name="my:signOff">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>
            <child-association name="my:processSteps">
               <source>
                  <mandatory>false</mandatory>
                  <many>false</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: Fachbereichszuordnung –>
      <aspect name="my:Fachbereichszuordnung">
         <title>Fachbereichszuordnung</title>
         <properties>
            <property name="my:Fachbereich">
               <type>d:text</type>
               <constraints>
                 <constraint ref="my:Fachbereich" />
               </constraints>
            </property>
         </properties>
      </aspect>
     
   </aspects>
  
</model>

But i got this error in alfresco.log:

[16:37:16,799 INFO  [org.alfresco.repo.dictionary.DictionaryDAO] Loading model from alfresco/extension/exampleModel.xml
16:37:16,886 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [/data/opt/alfresco/tomcat/shared/classes/alfresco/extension/example-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap model alfresco/extension/exampleModel.xml
Caused by:
org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap model alfresco/extension/exampleModel.xml
   at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:111)
   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:1160)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1122)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:273)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
   at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
   at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:448)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
   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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: Failed to parse model
   at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:99)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:106)
   … 42 more
Caused by: org.jibx.runtime.JiBXException: Expected end tag, found start tag "{http://www.alfresco.org/model/dictionary/1.0}constraint" (line 21, col 52)
   at org.jibx.runtime.impl.UnmarshallingContext.toEnd(UnmarshallingContext.java:548)
   at org.jibx.runtime.impl.UnmarshallingContext.parsePastEndTag(UnmarshallingContext.java:805)
   at org.alfresco.repo.dictionary.JiBX_root_projects_repository_source_java_org_alfresco_repo_dictionary_m2bindingM2Model_access.unmarshal()
   at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2515)
   at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2675)
   at org.alfresco.repo.dictionary.M2Model.createModel(M2Model.java:94)
   … 43 more
16:37:16,893 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/alfresco]] 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 'extension.dictionaryBootstrap' defined in file [/data/opt/alfresco/tomcat/shared/classes/alfresco/extension/example-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap model alfresco/extension/exampleModel.xml
Caused by:
org.alfresco.service.cmr.dictionary.DictionaryException: Could not import bootstrap model alfresco/extension/exampleModel.xml
   at org.alfresco.repo.dictionary.DictionaryBootstrap.bootstrap(DictionaryBootstrap.java:111)

Whats going wrong with my constraints-Defintion  Smiley Sad ?
Wrong order?  :?:
10 REPLIES 10

mikeh
Star Contributor
Star Contributor
Hi,

Probably just this typo on line 17:
<contraints> 


Mike

schneika
Champ in-the-making
Champ in-the-making
Sorry, the typo was corrected, but i got a new error, please see above. Wrong tags in wrong order? But what is correct?

davidc
Star Contributor
Star Contributor
I just used the java utility TestModel and the corrected model is fine.  It's definitely <contraints> that's the issue.

schneika
Champ in-the-making
Champ in-the-making
Oh sorry! You are right, of course. im very blind!  Smiley Surprisedops:
contraints - > constraints

roby71
Champ in-the-making
Champ in-the-making
Hi,

Could you show me where can I find Alfresco's TestModel utility that you have mentioned?

thanks very much
regards,

rivarola
Champ on-the-rise
Champ on-the-rise
Hello,

It is packaged in the repository.jar of your Alfresco installation.
For a sample command line use have a look at http://forums.alfresco.com/viewtopic.php?t=5238

You can alternatively get it in the Repository project java sources and launch it from your IDE.

priyanka_nayak
Champ in-the-making
Champ in-the-making
I need an aspect with drop-down box..so wot code do I add for that in my exampleModel.xml.

roby71
Champ in-the-making
Champ in-the-making
Hi,

first step is to add a constraint in the your customModel.xml

for example:

   <!– Definition of new constraints –>
     <constraints>
      <constraint name="custom:myLanguagesAllowedList" type="LIST">
       <parameter name="allowedValues">
          <list>
             <value>IT</value>
             <value>EN</value>
             <value>FR</value>
             … and so on…
           </list>
       </parameter>
      </constraint>
     </constraints>

second step is to add def of your custom aspect:

  <aspects>
        
         <aspect name="custom:myAspect">
            <title>My Aspect Title</title>
            <properties>
               <property name="custom:myLanguageField">
                  <title>Languages avaiable</title>
                  <type>d:text</type>
                  <mandatory>true</mandatory>
                  <constraints>
                    <constraint ref="custom:myLanguagesAllowedList"/>
                  </constraints>
               </property>
               <property name="custom:myCustomerName">
                  <title>Customer name</title>
                  <type>d:text</type>
                  <mandatory>true</mandatory>
               </property>
              </properties>
         </aspect>
      </aspects>

see also:
http://wiki.alfresco.com/wiki/Constraints

Hope it helps,
regards

priyanka_nayak
Champ in-the-making
Champ in-the-making
Hi roby,
For the code you have sent for drop-down wot changes we have to make in web-client-confi-custom.xml…
I have done it as below:
code:

<config evaluator="aspect-name" condition="my:xyz">
   <property-sheet>
     <seperator name="sepCust2" display-label="Customer Details"   component-generator="HeaderSeparatorGenerator"/>
       <show-property name="my:CustomerAge"/>
      <show-property name="my:myLanguageField"/>
   </property-sheet>
  </config>

Is it ok or do I have to make some other changes too…