Sunday, October 26, 2014

Testing new Alfresco content models

There are several ways to test new content models that are being developed:
  1. Create a new model, register the new model with the repository by bootstrap it to extension.dictionaryBootstrap.  Restart the server and see if any errors are thrown.  This is slow.
  2. Deploy it via Alfresco Explorer /Company Home/Data Dictionary/Models.  See if any errors are thrown.  Also can be slow.
  3. Test it against alfresco’s TestModel class.  Fastest.
Environment used:

Windows 7 64-bit
Alfresco 4.1.4 running on embedded tomcat using Maven Alfresco SDK 1.1.1
Oracle jdk “1.7.0_67”

Windows 7 64-bit
Alfresco 5.1.e running on embeeded tomcat using Maven Alfresco SDK 2.2.0
Oracle jdk "1.8.0_66"

Solution
  1. Create a new model and register it with spring bean.  The parent and depends-on must be set to “dictionaryModelBootstrap” and “dictionaryBootstrap” respectively.  Restart alfresco server and see if any errors thrown.

  2. <bean id=”cherryshoe_dictionaryBootstrap” parent=”dictionaryModelBootstrap” depends-on=”dictionaryBootstrap”>
    <property name=”models”>
    <list>
    <value>alfresco/extension/model/cherryshoeModel.xml</value>
    </list>
    </property>
    </bean>
    
  3. Upload the cherryshoeModel.xml to /Company Home/Data Dictionary/Models.  See if any errors are thrown.
  4. Test it against alfresco’s TestModel class.
For example:
Let’s remove the last “>” in “</model>” and see what happens during the validation
  • Locate the folder where your custom model is: D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\src\main\amp\config\alfresco\module\alfresco-amp\model\cherryshoeModel.xml
  • Locate the Alfresco Tomcat WEB-INF\classes folder: D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\target\alfresco-amp-war\WEB-INF\classes
  • Locate the Alfresco Tomcat WEB-INF\lib folder: D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\target\alfresco-amp-war\WEB-INF\lib
  • Change to the folder where your model is:
chdir /D D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\src\main\amp\config\alfresco\module\alfresco-amp\model.
  • The classpath needs to defined for where your model is (this folder), the tomcat WEB-INF\classes folder, and tomcat WEB-INF\lib folder:
java -classpath  “.;D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\target\alfresco-amp-war\WEB-INF\lib\*;D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\target\alfresco-amp-war\WEB-INF\classes” org.alfresco.repo.dictionary.TestModel cherryshoeModel.xml
  • NOTE: if you had a custom model that is imported within cherryshoeModel.xml, you would put the base model first in the command.  Also, if the model is in a different folder, then just add that as one of the classpath paths.  For example, if cherryshoeModel.xml imported custom model DIFFERENT_PATH/importMeModel.xml:
java -classpath  “.;D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\target\alfresco-amp-war\WEB-INF\lib\*;D:\workspaces\cherryshoe-team\cherryshoe-project\alfresco4\alfresco-amp\target\alfresco-amp-war\WEB-INF\classes;DIFFERENT_PATH” org.alfresco.repo.dictionary.TestModel importMeModel.xml cherryshoeModel.xml
  • When running the above java command, the output is as follows, you will see the error all the way at the bottom:
Failed to parse model
Error accessing document
no more data available – expected end tag </model> to close start tag <model> from line 3, parser stopped on TEXT seen …</namespaces>“.Testing dictionary model definitions…
alfresco/model/dictionaryModel.xml
alfresco/model/systemModel.xml
org/alfresco/repo/security/authentication/userModel.xml
alfresco/model/contentModel.xml
alfresco/model/wcmModel.xml
alfresco/model/applicationModel.xml
alfresco/model/bpmModel.xml
alfresco/model/wcmAppModel.xml
cherryshoeModel.xml
2014-10-23 11:41:23 WARN  ConfigurationFactory:134 – No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/D:/workspaces/cherryshoe-team/cherryshoe-project/alfresco4/alfresco-amp/target/alfresco-amp-war/WEB-INF/lib/ehcache-core-2.0.0.jar!/ehcache-failsafe.xml
2014-10-23 11:41:24 WARN  ConfigurationFactory:134 – No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/D:/workspaces/cherryshoe-team/cherryshoe-project/alfresco4/alfresco-amp/target/alfresco-amp-war/WEB-INF/lib/ehcache-core-2.0.0.jar!/ehcache-failsafe.xml
2014-10-23 11:41:24 WARN  CacheManager:566 – Creating a new instance of CacheManager using the diskStorePath “C:\Users\jhsu\AppData\Local\Temp\” which is already used by an existing CacheManager.
The source of the configuration was net.sf.ehcache.config.generator.ConfigurationSource$DefaultConfigurationSource@3b1a82fd.
The diskStore path for this CacheManager will be set to C:\Users\jhsu\AppData\Local\Temp\\ehcache_auto_created_1414078884233.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.
2014-10-23 11:41:24 INFO  DictionaryDAO:239 – Init Dictionary: model count = 0 in 14 msecs [Thread[main,5,main]]
2014-10-23 11:41:24 INFO  UpdateChecker:97 – New update(s) found: 2.4.7 [http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.4].
Please check http://ehcache.org for the latest version.
2014-10-23 11:41:24 INFO  UpdateChecker:97 – New update(s) found: 2.4.7 [http://www.terracotta.org/confluence/display/release/Release+Notes+Ehcache+Core+2.4].
Please check http://ehcache.org for the latest version.
Found an invalid model…
09230001 Could not import bootstrap model cherryshoeModel.xml
09230000 Failed to parse model
Error accessing document
no more data available – expected end tag </model> to close start tag <model> from line 3, parser stopped on TEXT seen …</namespaces>\r\n    \r\n    \r\n
\r\n    \r\n    \r\n</model… @28:8
  • After fixing the end tag </model>, rerun the validation, the end output should say:
Models are valid.

No comments:

Post a Comment

I appreciate your time in leaving a comment!