Views
Advanced AMP Development
From alfrescowiki
AMP file structure
/
|
|- /config
|
|- /lib
|
|- /licenses
|
|- /web
|
|- /jsp
|
|- /css
|
|- /images
|
|- /scripts
|
|- module.properties
|
|- file-mapping.properties
Structure config directory
/config
|
|- /alfresco
|
|- /module
|
|- /moduleid
|- module-context.xml
|
|- /boostrap
| |-script-import.xml
| |-groups-import.xml
| |-content-template-import.xml
| |-space-to-import.xml
| |-/space-to-import
|
|- /context
| |-bootstrap-context.xml
| |-action-context.xml
| |-others-context.xml
|
|- /messages
|
|- /model
| |-modulenameModel.xml
|
|- /script
| |-somescript.js
|
|- /template
| |-sometemplate.ftl
|
|- /ui
| |-web-client-custom.xml
|
|- /workflow
|-workflowmodulename_workflowModel.xml
|-workflowmodulename_processdefinition.xml
|-workflowmodulename-messages.properties
/alfresco/module/moduleid
For alfresco to pickup your module resources these have to be placed (these usually were placed in the <shared>/alfresco/extension directory) in the webapps/alfresco/WEB-INF/classes/alfresco/module/<moduleid> subdirectory as you can see in this snippet from WEB-INF/classes/alfresco/module-context.xml
<!-- Import of installed modules --> <import resource="classpath*:alfresco/module/*/module-context.xml"/> <import resource="classpath*:alfresco/module/*/module-uninstall-context.xml"/>
contents of module-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<import resource="classpath:alfresco/module/<moduleid>/context/bootstrap-context.xml" />
<import resource="classpath:alfresco/module/<moduleid>/context/action-context.xml" />
<import resource="classpath:alfresco/module/<moduleid>/context/scheduled-action-context.xml" />
<bean id="<moduleid>.ConfigBootstrap" class="org.alfresco.web.config.WebClientConfigBootstrap" init-method="init">
<property name="configs">
<list>
<value>classpath:alfresco/module/<moduleid>/ui/web-client-xml</value>
</list>
</property>
</bean>
</beans>
Using bootstrap
When installing a Module into the Alfresco system you probably want to import some stuff like spaces, templates, scripts etc. For this purpose you can use the boostrap mechanism.
The first line in module-context.xml:
<import resource="classpath:alfresco/module/<moduleid>/context/bootstrap-context.xml" />
points to
bootstrap-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Registration of new models -->
<bean id="<moduleid>.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/module/<moduleid>/model/modulenameModel.xml</value>
</list>
</property>
</bean>
<!-- Bootstrap -->
<bean id="<moduleid>.bootstrapSpaces" class="org.alfresco.repo.module.ImporterModuleComponent"
parent="module.baseComponent">
<property name="moduleId" value="<moduleid>" />
<property name="name" value="<moduleid>.bootstrapSpaces" />
<property name="description" value="Initial data requirements" />
<property name="sinceVersion" value="1.0" />
<property name="appliesFromVersion" value="1.0" />
<!-- Data properties -->
<property name="importer" ref="spacesBootstrap"/>
<property name="bootstrapViews">
<list>
<props>
<prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.content.childname}</prop>
<prop key="location">alfresco/module/<moduleid>/bootstrap/content-template-import.xml</prop>
</props>
<props>
<prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.scripts.childname}</prop>
<prop key="location">alfresco/module/<moduleid>/bootstrap/script-import.xml</prop>
</props>
<props>
<prop key="path">/${spaces.company_home.childname}</prop>
<prop key="location">alfresco/module/<moduleid>/bootstrap/space-to-import.xml</prop>
</props>
</list>
</property>
</bean>
<bean id="<moduleid>.bootstrapGroups" class="org.alfresco.repo.module.ImporterModuleComponent"
parent="module.baseComponent">
<property name="moduleId" value="<moduleid>" />
<property name="name" value="<moduleid>.bootstrapGroups" />
<property name="description" value="Initial data requirements" />
<property name="sinceVersion" value="1.1" />
<property name="appliesFromVersion" value="1.1" />
<!-- Data properties -->
<property name="importer" ref="userBootstrap"/>
<property name="bootstrapViews">
<list>
<props>
<prop key="path">/${alfresco_user_store.system_container.childname}/sys:authorities</prop>
<prop key="location">alfresco/module/<moduleid>/bootstrap/import_groups.xml</prop>
</props>
</list>
</property>
</bean>
<bean id="<moduleid>.workflowBootstrap" parent="workflowDeployer">
<property name="workflowDefinitions">
<list>
<props>
<prop key="engineId">jbpm</prop>
<prop key="location">alfresco/module/<moduleid>/workflow/workflowmodulename_processdefinition.xml</prop>
<prop key="mimetype">text/xml</prop>
<prop key="redeploy">true</prop>
</props>
</list>
</property>
<property name="models">
<list>
<value>alfresco/module/<moduleid>/workflow/workflowmodulename_workflowModel.xml</value>
</list>
</property>
<property name="labels">
<list>
<value>alfresco/module/<moduleid>/workflow/workflowmodulename</value>
</list>
</property>
</bean>
</beans>