Alfresco Documentation
Published on Alfresco Documentation (https://docs.alfresco.com)

Home > Alfresco Enterprise 4.0.2 > Administering > Managing content stores > Managing the content store

Managing the content store

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.

  • Content store selector configuration example [1] 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.
  • Using the new content store [2] The new content store is set using the cm:storeName property.
  • Content Store Selector full configuration example [3] The following example shows the full definition of creating new stores using the Content Store Selector.
Parent topic: Managing content stores [4]

Content store selector configuration example

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:

  1. Create a file called sample-content-store-selector-context.xml in the extension directory.
  2. Define two new file stores.
  3. Declare a storeSelectorContentStore to be the system's primary content store.
  4. Declare the mapping between the store name and store instances.
  5. Add the extra stores to the list to be handled by the eagerContentStoreCleaner.
  1. Open the sample-content-store-selector-context.xml file.
  2. 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 alfresco-global.properties file.

  3. 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>
  4. 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.

Parent topic: Managing the content store [5]

Using the new content store

The new content store is set using the cm:storeName property.

The cm:storeName property can be set in number of ways:

  • Manually, by exposing this property so its value can be set by either Explorer or Share
  • 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

The expected behavior is as follows:

  • 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.
Parent topic: Managing the content store [5]

Content Store Selector full configuration example

The following example shows the full definition of creating new stores using the Content Store Selector.

This configuration must be saved as an 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.
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

   <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>

   <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>

<!-- Point the ContentService to the 'selector' store -->
   <bean id="contentService" parent="baseContentService">
      <property name="store">
         <ref bean="storeSelectorContentStore" />
      </property>
   </bean>

   <!-- Add the other stores to the list of stores for cleaning -->
   <bean id="eagerContentStoreCleaner" class="org.alfresco.repo.content.cleanup.EagerContentStoreCleaner" init-method="init">
      <property name="eagerOrphanCleanup" >
         <value>${system.content.eagerOrphanCleanup}</value>
      </property>
      <property name="stores" >
         <list>
            <ref bean="fileContentStore" />
            <ref bean="firstSharedFileContentStore" />
            <ref bean="secondSharedFileContentStore" />
         </list>
      </property>
      <property name="listeners" >
         <ref bean="deletedContentBackupListeners" />
      </property>
   </bean>
   
</beans>

The following example shows the web-client-config-custom.xml file:

 <!-- Configuring in the cm:storeSelector aspect -->
   <config evaluator="aspect-name" condition="cm:storeSelector">
      <property-sheet>
         <show-property name="cm:storeName" />
      </property-sheet>
   </config>
   <config evaluator="string-compare" condition="Action Wizards">
      <aspects>
         <aspect name="cm:storeSelector"/>
      </aspects>
   </config>
   ...
Parent topic: Managing the content store [5]

Source URL: https://docs.alfresco.com/4.0/concepts/store-manage-content.html

Links:
[1] https://docs.alfresco.com/../tasks/store-filestore-define.html
[2] https://docs.alfresco.com/../concepts/store-using.html
[3] https://docs.alfresco.com/../concepts/store-config-fullexample.html
[4] https://docs.alfresco.com/../concepts/manage-cs-home.html
[5] https://docs.alfresco.com/../concepts/store-manage-content.html