Geeks With Blogs
Mark Jones

SAF contains 6 ready-to-use Actions that allow the Exporting and Importing of :

- List Items

- Lists

- Webs

The 3 pairs of Actions that allow you to do this, are namely :

- ExportListItem & ImportListItem

- ExportList & ImportList

- ExportWeb & ImportWeb

The actions are listed as pairs, for convenience, although there is nothing that mandates that they have to be run one after the other. In fact, you can export a List and import it into a completely different Farm months later if you so wish. In addition to this, although each pairing exports and imports different types of content, they all follow the same process, which is  :

1. Export to a Content Migration Package (CMP) according to settings specificied in the “Export” Action.

2. Import from a CMP file according to settings specificed in the “Import” Action.

In principal that’s it! If you download the source code from here : http://SAF.Codeplex.com, you will find some useful examples at the locations listed below :

  1. {YourDrive}\src\CollaborisSaf.SampleFeatures\12\TEMPLATE\FEATURES\WSS.ContentMigration.CopyListItem
  2. {YourDrive}\src\CollaborisSaf.SampleFeatures\12\TEMPLATE\FEATURES\WSS.ContentMigration.CopyList
  3. {YourDrive}\src\CollaborisSaf.SampleFeatures\12\TEMPLATE\FEATURES\WSS.ContentMigration.CopyWeb

The examples all demonstrate how to export and import in one go from a Feature. However, in reality, you will more than likely Export from a publishing Farm (using the STSAdm Adapter for SAF) and then do the Import from a Feature. This means that your CMP can then be easily checked into TFS and then triggered as part of a daily build.

Example : A Macro illustrating how to Export List Item(s) from a chosen List.

The example below contains a SAF macro that Exports a List Item (with an ID of ‘1’) from a list called ‘SportsList’ in a Web called ‘http://localhost/sports’. This will then create a CMP package called ‘Exported.cmp’. This CMP can then later be imported into a new web (in a new farm), using Import List Item (see next example).

<?xml version="1.0" encoding="utf-8" ?> 
<objects xmlns="http://www.springframework.net"> 
 
 <!-- Defines the main macro to process --> 
 <object id="MacroToProcess" type="Macro" > 
 <constructor-arg name="id" value="{41C43948-B22C-4acf-B833-00FA3FF537F1}" /> 
 <constructor-arg name="actions"> 
 <list element-type="IAction"> 
 
 <!-- Exports a List Item --> 
 <object name="ExportItems1" type="Action.ExportListItem"> 
 <property name="EntityList" ref="ExportListItemsList"/> 
 </object> 
 </list> 
 </constructor-arg> 
 </object> 
 
 <!-- Holds a list of individual list Items to export --> 
 <object id="ExportListItemsList" type="Entities"> 
 <constructor-arg> 
 <list> 
 <object type="Entity.ListItemExportSettings"> 
 <property name="SiteUrl" value=”http://localhost/Sports /> 
 <property name="ListName" value="SportsList" /> 
 <property name="ListItemId" value="1"/> 
 <property name="ExportSettings"> 
 <object type="Entity.ExportSettings"> 
 <property name="BaseFileName" value="Exported.cmp" /> 
 <property name="FileCompression" value="True" /> 
 <property name="FileLocation" value="c:\Temp\Migration" /> 
 <property name="FileMaxSize" value="100000" /> 
 <property name="OverwriteExistingDataFile" value="True" /> 
 <property name="IncludeSecurity" value="False" /> 
 <property name="IncludeVersions" value="True" /> 
 <property name="LogFilePath" value="c:\Temp\Migration\ExportLog.txt" /> 
 </object> 
 </property> 
 </object> 
 <!--... More Objects to Export here - if needed ...--> 
 </list> 
 </constructor-arg> 
 </object> 
</objects> 
 
 

 

Example : A Macro illustrating how to Import List Items (s) into a destination List.

The example below contains a SAF macro that Imports a set of List Items from a CMP Package called ‘Exported.cmp’ into a list called ‘SportsList’ (contained in a Web called ‘http://IntegrationWeb/DestWeb1’).

<?xml version="1.0" encoding="utf-8" ?> 
<objects xmlns="http://www.springframework.net"> 
 
 <!-- Defines the main macro to process --> 
 <object id="MacroToProcess" type="Macro" > 
 <constructor-arg name="id" value="{41C43948-B22C-4acf-B833-00FA3FF537F1}" /> 
 <constructor-arg name="actions"> 
 <list element-type="IAction"> 
 <!-- Imports the List Item (from above) into a different List--> 
 <object name="ImportItems1" type="Action.ImportListItem"> 
 <property name="EntityList" ref="ImportListItemsList"/> 
 </object> 
 </list> 
 </constructor-arg> 
 </object> 
 
 <!-- Holds a list of items to Import --> 
 <object id="ImportListItemsList" type="Entities"> 
 <constructor-arg> 
 <list> 
 <object type="Entity.ListItemImportSettings"> 
 <property name="SiteUrl" value="http://IntegrationWeb/DestWeb1" /> 
 <property name="ListName" value="SportsList" /> 
 <property name="ImportSettings"> 
 <object type="Entity.ImportSettings"> 
 <property name="BaseFileName" value="Exported.CMP" /> 
 <property name="FileCompression" value="True" /> 
 <property name="FileLocation" value="c:\Temp\Migration" /> 
 <property name="RetainObjectIdentity" value="False" /> 
 <property name="IgnoreWebParts" value="False" /> 
 <property name="IncludeSecurity" value="False" /> 
 <property name="MakeInternalLinksRelative" value="True" /> 
 <property name="LogFilePath" value="c:\Temp\Migration\ImportLog.txt" /> 
 </object> 
 </property> 
 </object> 
 </list> 
 </constructor-arg> 
 </object> 
</objects> 
 
 

 

A couple of Important Points :

  1. The source and destination lists must be schematically identical.
  2. The account who the Macro runs under, must have relevant permissions to both the source and destination list. (Although this can be 2 different users).
  3. All 3 pairs of Actions require SharePoint SP1 as a minimum.
  4. Please feel free to ask any questions here, so that I can help to structure the documentation around your needs.
Posted on Tuesday, July 28, 2009 6:24 AM | Back to top


Comments on this post: Content Migration using SAF

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © SAF | Powered by: GeeksWithBlogs.net