The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Tridion::BusinessConnector - Interface to Tridion's "Business Connector"

VERSION

  Version 0.02, released April 2004
  CVS Version $Id: BusinessConnector.pm 18 2005-12-21 16:38:11Z tjc $

NOTICE

  Written by Toby Corkindale (toby (at) corkindale.net)
  Copyright (c) 2004, 2005 Toby Corkindale.

This Perl module is distributed under the terms of the LGPL:

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This license can be found at http://www.gnu.org/licenses/lgpl.html

I am not affiliated with Tridion. This module was not created with their aid, and is not supported by them.

SYNOPSIS

    use Tridion::BusinessConnector;
    my $bc = new Tridion::BusinessConnector(
                    hostname => 'tridionCMS',
                    username => 'DOMAIN/tjc',
                    password => 'p@ssw0rd'
                    );
    my $target_uri = shift(@ARGV);
    die("Invalid TCM URI\n") unless ($target_uri =~ /^tcm:\d+(\-\d+)*$/);
    my $item = $bc->GetItem($target_uri);
    print $item->toString(1);

DESCRIPTION

This module provides a handy interface to the Tridion CMS' SOAP interface, known as the "Business Connector" in their documentation. It handles things like escaping passwords, XML namespaces, request/response formats, and stuff like that.

This is the first version, and as such provides only a few functions, mainly at low levels. For everything other than GetItem and SaveItem issues, you will use the execute() function. At a later date I will add direct functions for DeleteItem, GetList, Publish, Search, and so on.

FUNCTIONS

new()

This function takes three parameters: hostname, username, password.

  • hostname - this is the host which this instance of the T::B module should talk to.

  • username - the username to connect with. Note that you may need to prefix it with the NTLM domain, if you're using that for authentication.

  • password - the password to connect with.

Example:

    use Tridion::BusinessConnector;
    my $bc = new Tridion::BusinessConnector(
                    hostname => 'tridionCMS',
                    username => 'DOMAIN/tjc',
                    password => 'p@ssw0rd'
                    );

execute()

This function takes one parameter: a string containing a complete XML request.

This means you need to create all the request generation yourself, etc. This function is mainly used internally by the higher level interfaces, but is provided so you can call Tridion functions that have not yet got a high-level function in this module.

GetItem()

This function takes one parameter: a string containing a TCM URI.

It will query the Tridion system, and retrieve whatever that URI matches. It will not check-out or lock the item.

Upon success, the function will return a XML::LibXML::Document.

The function will die on failure, so you can call it from an eval {}; setup to catch the failure and get the error message if you like, or just let it dump to stderr. This 'die on fail' behaviour will not change in future releases, but I think I will add some better pre-processing of the error message. Also, be warned that a non-fatal error will probably be changed to not die, but just return undef, at some stage in the future.

SaveItem()

This function takes three parameters:

  • An XML::LibXML::Document, which contains the item to be saved.

  • The URI to save the data to. If you want to create a new item, then pass in the magic value of 'tcm:0-0-0' here.

  • The "context" of the item - ie. the folder or structure group which you want the item to appear within. If you are saving an existing item, then you must leave this set to 'tcm:0-0-0' instead. (Tridion's requirement, not mine.)

Note that for reasons that are not entirely clear to me, one cannot just get an item, change the bits you want, and then save it back. The data included with a GetItem includes sundry information from Tridion, such as context, permissions, status, etc. but any attempt to save an item back that includes that information will fail! So, remember to strip out it out before saving..