Sometimes it is also necessary to bootstrap folders and files into locations outside sites. This can also be done with the generic bootstrap patch as follows:
<bean id="org.alfresco.tutorial.bootstrap.patch.foldersAndFilesLoader"
class="org.alfresco.repo.admin.patch.impl.GenericBootstrapPatch"
parent="basePatch" >
<property name="id"><value>org.alfresco.tutorial.bootstrap.patch.foldersAndFilesLoader</value></property>
<property name="description"><value>org.alfresco.tutorial.bootstrap.patch.foldersAndFilesLoader.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>${version.schema}</value></property>
<property name="targetSchema"><value>99999</value></property>
<property name="importerBootstrap">
<ref bean="spacesBootstrap" />
</property>
<!-- Can be used to check if something already exists, if it does then the patch will not be executed -->
<property name="checkPath">
<value>/${spaces.company_home.childname}/cm:acmedocument.txt</value>
</property>
<property name="bootstrapView">
<props>
<prop key="path">/${spaces.company_home.childname}</prop>
<prop key="location">alfresco/module/bootstrap-content-repo/bootstrap/import-folders-and-files.xml</prop>
</props>
</property>
</bean>
The content of the import-folders-and-files.xml XML file has the same structure as the XML container in the Contents.acp we get when exporting a site. So to bootstrap a file it will look like this:
<?xml version="1.0" encoding="UTF-8"?> <view:view xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:view="http://www.alfresco.org/view/repository/1.0" xmlns:sys="http://www.alfresco.org/model/system/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0" xmlns:acme="http://www.acme.org/model/content/1.0"> <acme:document view:childName="cm:acmedocument.txt"> <view:aspects> <cm:auditable></cm:auditable> <sys:referenceable></sys:referenceable> <cm:titled></cm:titled> <sys:localized></sys:localized> <app:inlineeditable></app:inlineeditable> </view:aspects> <view:acl></view:acl> <view:properties> <cm:name>acmedocument.txt</cm:name> <sys:node-dbid>854</sys:node-dbid> <sys:store-identifier>SpacesStore</sys:store-identifier> <sys:locale>en_GB_</sys:locale> <cm:content>contentUrl=classpath:alfresco/module/bootstrap-content-repo/bootstrap/someacmedoc.txt|mimetype=text/plain|size=30|encoding=UTF-8|locale=en_GB_</cm:content> <acme:documentId>DOC001</acme:documentId> <cm:title> <view:mlvalue view:locale="en">SomeTitle</view:mlvalue> </cm:title> <cm:modified>2015-09-10T16:11:07.875+01:00</cm:modified> <sys:node-uuid>34e4a654-b45e-4be1-80db-25da1e4c82a7</sys:node-uuid> <app:editInline>true</app:editInline> <cm:created>2015-09-10T16:10:49.142+01:00</cm:created> <sys:store-protocol>workspace</sys:store-protocol> <cm:creator>admin</cm:creator> <cm:description> <view:mlvalue view:locale="en">SomeDesc</view:mlvalue> </cm:description> <cm:modifier>admin</cm:modifier> </view:properties> </acme:document> </view:view>
Besides using patches to bootstrap content there is also the ImporterModuleComponent that can be used to bootstrap/import content into the Repository, for more information about this see Module Components.