Detecting language please wait for.......
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:
Important note: Purposes are case-sensitive, so please make sure that you use proper titles if following instructions.
Lets start with first case:
In order to extend our Business Process Type with new Live environment:
Create new Topology Type with two purposes:
Add-TtmCdTopologyType -Id StagingAndLive -Name StagingAndLive -EnvironmentPurposes @('Staging','Live')
Using CoreService API execute following code:
using (SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient())
var readOptions = new ReadOptions();
var bptId = "tcm:1-7-4096";
var cdTopologyTypeIdNew = "StagingAndLive";
var purposeToAdd = "Live";
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();
bpt.TargetTypes = bptTargetTypesList.ToArray();
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
In order to run Convert-TcmPublishStates cmdlet:
In Powershell execute:
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.
+1, good article