The Content Store Selector provides a mechanism to control the store used for the content file associated with a particular content item. By applying the cm:storeSelector aspect and setting its cm:storeName property to the name of a selectable store, the content will be automatically moved from its current location to the new store. The store does not, therefore, store content itself, it defines and manages those stores that are available for selection.
This allows storage polices to be implemented to control which underlying physical storage is used, based on your applications needs or business policies. For example, if you have a fast (and expensive) local disk, you can use this to store the files that you want to ensure are served for best performance; however, infrequently used files may be stored on lower cost, slower storage.
In this example, we will define two additional file stores in addition to the standard default file store. By setting the cm:storeName to 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.
Define two new file stores.
Declare storeSelectorContentStore to be the system's primary content store.
Declare the mapping between store names and store instances.
Add the extra stores to the list to be handled by the eagerContentStoreCleaner.
Define the new file stores
The following configuration snippet defines two new stores. In this case, the physical location is relative to the dir.root property defined in alfresco-global.properties file. Note: The value for a new store directory may be a valid UNC path.
The cm:storeName property can be set in number of ways:
Manually, by exposing this property so its value can be set by either the Explorer or Share clients
Running a script action that sets the cm:storeName property value within the script
Using a rule that runs a script action to set the property
When the cm:storeSelector aspect is not present or is removed, the content is copied to a new location in the 'default' store.
When the cm:storeSelector aspect is added or changed, the content is copied to the named store.
Under normal circumstances, a trail of content will be left in the stores, just as it would be if the content were being modified. The normal processes to clean up the orphaned content will be followed.
Full configuration example
The following shows the complete configuration example. This should be saved as a extension, for example, <extension>\sample-content-store-selector-context.xml. Note: The list of stores available can be set by updating the list under the <property name='storesByName'> property.