SDL Web 8: Migrating From Old- to New-Style Publishing (Part 3 of 3: extending Business Process Types)

In the previous two posts, we shared a cmdlet and example script for repurposing publishing states and generating publishing configuration. In this post, we provide example Content Manager code to handle other scenarios that may come up in migration projects.

 As an administrative, system-level task, the UI does not expose ways to manipulate the targets used in Business Process Types. However, the Content Manager API (Core Service) lets you extend an existing Business Process Type (BPT) without re-creating all target types.

Consider the following scenarios:

  1. Adding a Purpose to a BPT. You have a BPT with a single Content Delivery (CD) environment (e.g. Staging). Later you want to add a Live environment. It is possible to define another Topology type and then update a BPT by specifying a new Topology Type to add an extra Target Type for a new purpose.
  2. Consolidating BPTs. You have two BPTs that each have an environment (e.g. a BPT with just Staging and another with just Live). You now want to combine them into a single BPT with a single purpose (e.g. Staging environment)

Important note: Purposes are case-sensitive, so please make sure that you use proper titles if following instructions.

Adding a Purpose to a BPT

Lets start with first case:

  1. In Topology Manager we have only one Topology Type which has 'Staging' purpose:
     
  2. In Content Manager we have Business Process Type which use this Topology Type:

In order to extend our Business Process Type with new Live environment:

  1. Create new Topology Type with two purposes:

    Add-TtmCdTopologyType -Id StagingAndLive -Name StagingAndLive -EnvironmentPurposes @('Staging','Live')
  2. Using CoreService API execute following code:

    using (SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient())
    {
        //Initialize paramenters
        var readOptions = new ReadOptions();
        var bptId = "tcm:1-7-4096";
        var cdTopologyTypeIdNew = "StagingAndLive";
        var purposeToAdd = "Live";
     
        //Reading BPT
        var bpt = (BusinessProcessTypeData)client.Read(bptId, readOptions);
     
        //Creating new Target Type for new Purpose
        var targetTypeNew = new TargetTypeData
        {
            Id = "tcm:0-0-0",
            Title = bpt.Title + " " + purposeToAdd,
            Description = bpt.Title + " " + purposeToAdd,
            Purpose = purposeToAdd
        };
     
        //Setting new Topology Type Id on BPT
        bpt.CdTopologyTypeId = cdTopologyTypeIdNew;
     
        //Adding new Target Type to BPT
        var bptTargetTypesList = bpt.TargetTypes.ToList();
        bptTargetTypesList.Add(targetTypeNew);
        bpt.TargetTypes = bptTargetTypesList.ToArray();
     
        //Update BPT
        client.Update(bpt, readOptions);
    }

Consolidating BPTs

For the second case you need to do the same, but the problem here it that you have created a new Target Type for Live purpose in first BPT but items were published to Target Type for Live purpose in a different BPT.

To avoid re-publishing everything to new Target Type you can use the previously mentioned cmdlet to migrate all publish states from an old Target Type to a new one (depending on your database type):

Convert-TcmPublishStates -SourceId 1 -SourceType TargetType -DestinationTargetTypeId 2 -DatabaseType MsSql-Server localhost -DatabaseName Tridion_cm -User sa -Password password

Convert-TcmPublishStates -SourceId 1 -SourceType TargetType -DestinationTargetTypeId 2 -DatabaseType Oracle-NetServiceName OracleInstance -SchemaName Tridion_cm -User sys -Password password -AsSysDba

  

How to Run

In order to run Convert-TcmPublishStates cmdlet:

  1. Copy Tridion.ContentManager.PublishingConfigurationHelper.dll and Tridion.ContentManager.PublishingConfigurationHelper.dll-help.xml to any folder on your machine
  2. In Powershell execute:

    Import-Module "FULL_PATH_TO_Tridion.ContentManager.PublishingConfigurationHelper.dll_FILE"
  3. To get help on Convert-TcmPublishStates cmdlet execute:

    Get-Help Convert-TcmPublishStates -Full

     

We hope these posts helped you understand Topology Manager a bit more as well as give you additional tools and examples for your migration projects. 

Anonymous