Importing Commerce server Profiles – Deployment utility


Introduction


Deploying commerce server profiles is a repetitive task / requirement in many commerce server engagements. Commerce server profile system is extensible and supports various data bases as data stores. Every engagement takes this advantage and extends the profiles based on the project requirement. Question about profile deployment is very common in all the commerce server engagements with some differing profile implementations. Some projects use SQL server as data source and some of them use the combination of SQL & AD. In all these cases, deploying commerce server profiles still stands as a common requirement. While thinking about this, I got the idea of developing a generic deployment tool which can be used across engagements with the support of extensibility to deal with project specifics. Common solutions across implementations , good old concept of Design Patterns strikes my mind. Very powerful and difficult concept to convince people….. Let's target the problem with design patterns…


Problem statement


Commerce server represents profiles in xml format and provides options to export and import profiles of commerce site. In the development environment we use Commerce Server manager to import or export profiles. Automating this will be great value add in the development life cycle. The tool will also play a very vital role in defining the automated build and deploy process for engagements. Commerce server runtime provides api's to import and export profiles programmatically. The code is very simple and doesn't take much time to implement specific to an engagement. The main idea of this tool is not to deal with the project specifics; instead it should be generalized tool which can be adopted in any commerce server engagements with the provision of extensibility. Let' dive in to the technical specification of the requirement.


Technical Specification


Exporting a profile is very generic and doesn't need any specific code to make it generic. It just expects a site name and output file name. The logic can be directly burned in the tool by getting the above specified parameters. Importing profile is little tricky. Commerce runtime API takes Profile/Bizdata connection string and the profile xml as the input to perform the process of import. The first parameter can be parameterized easily. Second parameter takes the profile xml file path. Every engagement would have implemented different profile data stores in commerce server profiles. Every data source expects certain parameters like connection string, Active directory credentials etc. Basically the xml file content needs to be updated with project specific implementation and then the same needs to be passed to commerce server runtime api's.


I have tailored the observer design pattern to achieve the same. Profile import tool has an initialization file named InitData.xml. Initdata xml represents the initialization data / parameters used by the tool to perform the process of import and export. The xml file also allows the users to specify handler's information. Handlers are nothing but Assembly & Type combination information stored in the initialization file. Before starting the process of import / export, the tool looks into the configured handlers and instantiates the same through reflection and call appropriate interface methods to parse the xml document. I also expect the configured Type to implement the IProfileDocumentHandler interface. Handlers are specific to a partition or data source defined in the profile schema. One Data source can map to multiple handlers. Import tool identifies all the data sources defined in the profile document and searches for the handlers in the initialization file (InitData.xml) and calls the appropriate handlers to modify the xml document. Code to modify the profile xml document is implemented in the handler implementation. This gives us a clean way to isolate import process and project specific information processing. It also gives chance to the implementers to customize the tool to their requirements. Initialization file also allow the users to specify custom initialization or configurable parameters.


Initialization File Format


<?xml version="1.0" encoding="utf-8" ?>


<InitData>


    <!--


     <SiteConnection>


        <SiteName>Commerce Site Name</SiteName>


        <BizConnectionString>


             Profile resouce connection string


        </BizConnectionString>


        <UserName> future use.</UserName >


        <Password></Password>


    </SiteConnection>


    -->


    <SiteConnection>


        <SiteName>Framework</SiteName>


        <BizConnectionString>Provider=SQLOLEDB;Data Source=local-CS;Initial Catalog=Framework_profiles;Integrated Security=SSPI;Network Library=;</BizConnectionString>


        <UserName></UserName >


        <Password></Password>


    </SiteConnection>


    <!--


     <DataSources>


        <Partition name="Commerce User Profile PartitionName">


        User can have there own inititalization paramterd under partition node.


        Same will be passed to the handlers in runtime.


            <connectionString>Target Connection String</connectionString>    


        </Partition>


          


     </DataSources>


     -->


    <DataSources>


        <Partition name="UserObjectDS">


            <connectionString>Provider=SQLOLEDB;Data Source=(local);Integrated Security=SSPI;Initial Catalog=site_profiles;</connectionString>


        </Partition>


        <Partition name="DataSource1">


            <connectionString> Provider=SQLOLEDB;Data Source=(local);Integrated Security=SSPI;Initial Catalog=site_profiles;</connectionString>


        </Partition>


    </DataSources>


    <!--


     <Handlers>


        <Handler partitionName="Commerce User Profile PartitionName">


            <assembly path ="Assembly Path" type="TypeName" enable="1"></assembly>


        </Handler>


        <Handler partitionName="Commerce User Profile PartitionName">


            <assembly path ="Assembly Path" type="TypeName" enable="1"></assembly>


        </Handler>


    </Handlers>


        


     Partition Name configured in handlers section should match with the partition name


     in the data sources section.


    -->


    <Handlers>


        <Handler partitionName=" UserObjectDS">


            <assembly path ="<fullpath>Handlers.dll" type="Microsoft.Commerce.ProfileManager.Handlers.ConnectionStringHandler" enable="1"></assembly>


        </Handler>


        <Handler partitionName=" DataSource1">


            <assembly path ="<fullpath>Handlers.dll" type="Microsoft.Commerce.ProfileManager.Handlers.ConnectionStringHandler" enable="1"></assembly>


        </Handler>


    </Handlers>


</InitData>    


SQL Connection String Handler implementation


Connection string handler can be used to handle any data sources which has SQL server as the data store. Handler expects connection string information in the following location in the initdata.xml.


<DataSources>


<Partition name="UserObjectDS">


            <connectionString>Provider=SQLOLEDB;Data Source=(local);Integrated Security=SSPI;Initial Catalog=site_profiles;</connectionString>


        </Partition>


</DataSources>


Handler uses this information to update the connection string information in the specified partition name in the profile document.


Profile Import Tool Usage


CSProfileManager import <Init data file Path> <Profile definition file path>


CSProfileManager export <Init data file Path> <xml file path to export>


Conclusion


Profile import tool can be customized with little dev effort to suit the requirement of a project. Tool provides extensibility based on observer pattern. Created SQL Connection String handler to handle to SQL based data sources. Similarly we can create handlers to handle other data stores like AD etc.

CSProfileManager.zip


Comments (2)
  1. jstangroome says:

    From attempting to use your CS Profile Manager, it seems your code only works in the scenario that each Data Source only has one partition each and the partition name is identical to the data source name and then it sets all partition connection strings to the last entry in the InitData file.

Comments are closed.

Skip to main content