Documentation Center

How to modify a baseline

Managing and updating version selection of your objects in a baseline.

Every publication version refers to a Baseline object. This Baseline object is the container responsible for tracking the selected versions for the publication.

A rough working example of the code is:
  1. First the code retrieves the baselineId of your incoming baseline name. A baseline name can be found in Publication Manager as metadata of a publication version. This baselineId is a required parameter for the other functions.
  2. Next the baseline information is retrieved, and the currently selected versions of the identifiers listed in logicalIds is printed.
  3. Then Content Manager prepares a baseline modifications container xml that increases the version numbers of logicalIds.

    Content Manager does this by specifying the action keyword, update to indicate that an existing item is updated.

    The source keyword Manual indicates that you must explicitly select the specified version. This is not a version selected through automated actions such as autocomplete.

using System;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
static void UpdateBaseline(ref string context)
{ 
  //Creating the objects
  InfoShareBaseline25.BaseLine25 myInfoShareBaseline25 = new InfoShareBaseline25.BaseLine25();
  //Redirecting the dynamic URL to the current test machine
  myInfoShareBaseline25.Url = baseUrl + "Baseline25.asmx";
  
  //Retrieving the baseline
  string baselineId = string.Empty;
  myInfoShareBaseline25.GetBaselineId(ref context, "Simply Recipes-v1-GUID-37FB2705-35B6-4E7C-9E44-A50F202884EF-2010/12/28 15:51:49", ref baselineId);
  Console.WriteLine("baselineId[" + baselineId + "]");
  string objectList = string.Empty;
  string baselineContent = string.Empty;
  myInfoShareBaseline25.GetBaseline(ref context, baselineId, "", ref objectList, ref baselineContent);

  //Printing some values for
  string[] logicalIds = { "HTTP---FEEDPROXY-GOOGLE-COM-R-ELISE-SIMPLYRECIPES-3-JVNVZLJQUQ-", "HTTP---FEEDPROXY-GOOGLE-COM-R-ELISE-SIMPLYRECIPES-3-TTE8-QPNHJC-" };
  XDocument xDocument = XDocument.Parse(baselineContent);
  var query = from obj in xDocument.Descendants("object")
              where ((string)obj.Attribute("ref") == logicalIds[0]) || ((string)obj.Attribute("ref") == logicalIds[1])
              select (string)obj.Attribute("ref") + "=" + (string)obj.Attribute("versionnumber");
  foreach (string objectVersion in query)
      Console.WriteLine(objectVersion);

  //Updating some values
  string[] LogicalIdNewVersions = { "2", "2" };
  string baselineChanges = @"
    <modifications>
      <object ref='" + logicalIds[0] + @"' action='update' versionnumber='" + LogicalIdNewVersions[0] + @"' source='Manual'/>
      <object ref='" + logicalIds[1] + @"' action='update' versionnumber='" + LogicalIdNewVersions[1] + @"' source='Manual'/>
    </modifications>";
  myInfoShareBaseline25.Update(ref context, baselineId, baselineChanges);
}