Quick Start Guide

Deleting 2 lists via a Feature

Its simple to call SAF from a SharePoint Feature Receiver by creating the following Feature.xml file :

<Feature   Id="222E5D98-253B-4b38-A222-6B4C5644A51F"
               Title="WSS.List.DeleteList"
               Description="Sample Feature illustrating how to Delete a List."
               Version="12.0.0.0"
               Hidden="FALSE"
               Scope="Web"
               DefaultResourceFile="core"
               xmlns="http://schemas.microsoft.com/sharepoint/"
               ReceiverAssembly="Collaboris.Saf,Version=1.3.0.0, Culture=neutral, PublicKeyToken=182db3eac6a9e195"
               ReceiverClass="Collaboris.Saf.Adapters.FeatureAdapter">

  <ElementManifests/>
   <Properties>
	   <!-- Defines a series of "Actions" to be run on "Do" and "Undo" -->
	   <Property Key="ActionsFile" Value="chain.xml" />

   </Properties>	
</Feature>


The points of note about the Feature Receiver above are as follows :

This line tells SharePoint where to find the SAF Assembly :
*ReceiverAssembly="Collaboris.Saf,Version=1.3.0.0, Culture=neutral, PublicKeyToken=182db3eac6a9e195""*

This line tells SharePoint which .net class implements the Feature Receiver :
*ReceiverClass="Collaboris.Saf.Adapters.FeatureAdapter"*

Lastly, we need to tell the Feature receiver exactly where the "Chain" of Actions resides. (Relative to the Feature.xml path).This is achieved by designating an "ActionsFile":
*<Property Key="ActionsFile" Value="chain.xml" />*

As far as the Feature goes, thats it! You deploy the feature in the normal way, either by copying to the 12 hive, or deploying via a WSP.

In order to delete the Lists (defined below) you need to give SAF an XML file in the following format. This file is actuall a Spring.Net Container, so enjoys many of the benefits that come with Spring.Net. The file looks like this :
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">

   <description>Defines Activation and Deactivation routines for Creating a Web</description>

   <object id="MacroToProcess" type="Macro" >
      <constructor-arg name="id" value="{21C84948-B22C-4acf-B223-00FA2FF52250}" />
      <constructor-arg name="actions">
         <list element-type="IAction">
            <object name="DeleteList1" type="Action.DeleteList">
               <property name="EntityList" ref="SetOfListsToDelete"/>
            </object>
         </list>
      </constructor-arg>
   </object>

   <!--   Holds a list SPLists to Delete.   -->
   <object id="SetOfListsToDelete" type="Entities">
      <constructor-arg>
         <list>

            <!-- Delete the 'Test Document Library' -->
            <object type="Entity.ListToDelete">
               <property name="SiteUrl" value="${CurrentWeb.Url}" />
               <property name="ListName" value="Test Document Library" />
               <!-- causes the list to goto the recyle bin -->
               <property name="Destroy" value="False" />
            </object>

            <!-- Delete the 'Pages Library' -->
            <object type="Entity.ListToDelete">
               <property name="SiteUrl" value="${CurrentWeb.Url}" />
               <property name="ListName" value="Pages" />
               <property name="Destroy" value="False" />
            </object>
				
          </list>
       </constructor-arg>
   </object>
</objects>


The file is best discussed in 2 parts (as illustrated in the comments).

Part 1 - The macro
This Part contains the Actions that you wish to do in your Feature. In this example, we have only one Action as we are just interesting in deleting a list.

Part 2 - The Entities
Each Action can take zero or many Entities. Entities are simplye POCO's and nothing more. They are a way to tell the Action about the state (or data) it needs to do. In this case we are asking the ListToDelete action to delete 2 Lists.

In short, thats It! There is a lot more flexibility you can do with a Chain, such as Stopping On Exceptions, Rolling Back and Place Holders, but, we are working on the documentation for that, so bear with us.
Last edited Jul 19 at 8:46 PM by MarkQjones, version 4
Comments
No comments yet.

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2009.10.27.15987