I am writing an application which will trigger workflow on any items that use ECL components when they are modified in the external content library. My original idea was to create a simple web service which receives messages from the external system with a signature something like the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml.Linq;
using Tridion.ContentManager;
using Tridion.ExternalContentLibrary.V2;
using Tridion.ContentManager.CoreService.Client;
namespace UrbanCherry.Net.Tridion.ECL
{
/// <summary>
/// Summary description for ECLUpdateService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// [System.Web.Script.Services.ScriptService]
public class ECLUpdateService : System.Web.Services.WebService
{
/// <summary>
/// UpdateECLItem will recieve a message that an ECL item has changed
/// </summary>
/// <param name="mountPoint">ID of the mountpoint I want to use</param>
/// <param name="itemID">External ID of the item</param>
/// <param name="actionType">Update type (Delete or Update)</param>
/// <returns></returns>
[WebMethod]
public string UpdateECLItem(String mountPoint, String itemID, ActionType actionType)
{
//Do my magic
return "OK";
}
}
}
My external id can easily be converted into the ECLURI
as follows:
String eclItemID = "ecl:" + pubID + "-" + mountPoint + "-" + itemID + "-img-file";
The first thing my service needs to do is map the ECLURI
to the TCMURI
of the stub item. There seems to be no method for doing this using the Core Service, but I can achieve this by using the SessionFactory
object as follows:
Session tcmSession = new Session();
IEclSession eclSession = SessionFactory.CreateEclSession(tcmSession);
String tcmURI = eclSession.TryGetTcmUriFromEclUri(eclSession.HostServices.CreateEclUri(eclItemID));
However, I understand that creating a new session object in external code is not supported/recommended. If this is really the case, the only solution I have is to create some kind of mapping database table to store the relationships. This seems like overkill when eclSession.TryGetTcmUriFromEclUri()
does exactly what I need.
Can anyone think of how I can either execute eclSession.TryGetTcmUriFromEclUri
from a supported context (which can be triggered from an external application), or mimic it in some other way without needing to create a custom lookup table?