The following example defines two file stores, in
addition to the standard default file store. By setting the
cm:storeName property to either of these new stores or the
default store, the content is automatically moved from its existing store to
the relevant new store.
A summary of the procedure is as follows:
- Create a file called sample-content-store-selector-context.xml in the extension directory.
- Define two new file stores.
- Declare a storeSelectorContentStore to be the system's primary content store.
- Declare the mapping between the store name and store instances.
- Add the extra stores to the list to be handled by the eagerContentStoreCleaner.
- Open the sample-content-store-selector-context.xml file.
-
Define the new file stores by adding the following bean
definitions:
<bean id="firstSharedFileContentStore" class="org.alfresco.repo.content.filestore.FileContentStore"> <constructor-arg> <value>${dir.root}/storeA</value> </constructor-arg> </bean> <bean id="secondSharedFileContentStore" class="org.alfresco.repo.content.filestore.FileContentStore"> <constructor-arg> <value>${dir.root}/storeB</value> </constructor-arg> </bean>
This configuration snippet defines two new stores. The physical location is relative to the dir.root property defined in the SkyVault-global.properties file.
-
Declare the storeSelectorContentStore to be the
primary content store by adding the following bean definition:
<bean id="contentService" parent="baseContentService"> <property name="store"> <ref bean="storeSelectorContentStore" /> </property> </bean>
-
Declare the mapping between store names and store
instances.
<bean id="storeSelectorContentStore" parent="storeSelectorContentStoreBase"> <property name="defaultStoreName"> <value>default</value> </property> <property name="storesByName"> <map> <entry key="default"> <ref bean="fileContentStore" /> </entry> <entry key="storeA"> <ref bean="firstSharedFileContentStore" /> </entry> <entry key="storeB"> <ref bean="secondSharedFileContentStore" /> </entry> </map> </property> </bean>
The list of stores is defined by the <property name="storesByName"> property. Any stores you want to be available to the storeSelectorContentStore should be listed under this property.