Skip to main content

Posts

A Java Core Service Client for SDL Tridion 2013

Since SDL Tridion 2013 is out for a few weeks, I thought I should upgrade the previous Core Service Java client to the latest Tridion version. The JAR distributable [direct link] for Core Service client SDL Tridion 2013 is available here:  https://code.google.com/p/yet-another-tridion-blog/source/browse/trunk/Core+Service+Java+Client/#Core%20Service%20Java%20Client%2Fdist There are no changes in its functionality. This is a compatibility release.

Intercepting Core Service traffic with Fiddler

Fiddler2 is a proxy that runs locally on your machine and stays in-between a client (i.e. typically your browser) and the remote server. It can this way intercept the communication between the two and display it in various formats. So, in order to intercept communication with the Core Service, one should configure their Core Service client application to use the Fiddler proxy. The proxy installs itself on your local machine (when Fiddler starts), and on port 8888. Intercepted communication shows up in Fiddler somewhat like this: So, how do I specify a proxy in my client application? That depends on the technology used. Java Core Service Clients There are several ways of doing this, but the idea is that we need to set two properties: http.proxyHost - the host name or IP of the proxy server (i.e. localhost for Fiddler); http.proxyPort - the port the proxy is listening to (i.e. 8888  for Fiddler); If you have access to the code, you can set them using the Syste...

Streamlining the Core Service Java Client

In a previous post ( http://yatb.mitza.net/2012/12/a-core-service-java-client.html ), I was presenting the Java client for Core Service. In this post, I decided to post the distributable JAR on my Google Code project page. You can find the JAR distributable  [direct link]  for Core Service Java client for Tridion 2011 SP1 HR1 at the following URL:  https://code.google.com/p/yet-another-tridion-blog/source/browse/trunk/Core+Service+Java+Client/#Core%20Service%20Java%20Client%2Fdist The only new feature of this distribution is the CoreServiceFactory class in package mitza.coreservice.client , which allows you to easily obtain a Core Service client object. The following methods are exposed: getBasicHttpClient() - Get the singleton CoreService client for the BasicHttp endpoint; getService()  - Get the singleton  CoreService2011  service object. This method is used internally by the  get*Client  methods. The logic uses a WSDL local to...

Resolve Static Links TBB

This week's TBB is about resolving Component links statically - i.e. at publish time. This is considered terribly bad practice , but sometimes, in the field, it is just what the custmer needs. It really goes against every Tridion principle and it will make the website completely inconsistent (e.g. dead links cannot be prevented). However, if you need to do it, this it how. The code below reads the 'Where Used' Pages for a Component. It takes the Page publish location URL and constructs a 'static' link to the Page. It will not even check if the page is published. public string ResolveLinkStatic( Engine engine, Package package, Component component) {     if (component.BinaryContent == null ) { // is Content Component         XmlElement node = component.GetListUsingItems(             new UsingItemsFilter (engine.GetSession()) {       ...

Resolve JS Images In Output TBB

The TBB of this week is Resolve JS Images In Output , originally written by my colleague Eric Huiza . Basically, the TBB does what the name says. It looks for certain images in the Output item and publishes them. The images have to be in TcmUri or WebDAV format and they must appear in the url('path') format. This is the format that a CSS background selector uses, for example, only that it appears in JavaScript. The TB transforms something like: document.getElementById(openingTitleId).style.background=     "url('/webdav/Content/Building Blocks/Assets/images/titlebar.gif') no-repeat"; into this: document.getElementById(openingTitleId).style.background=     "url('/assets/images/titlebar_tcm1-2.gif') no-repeat"; Description Name Resolve JS Images In Output TBB Type ·    T emplate in .NET Assembly Description Used to: ·     Resolve references to Multimedia ...

Resolve CSS Images in Output TBB

This week's TBB is Resolve CSS Images in Output TBB . This template identifies unresolved image references inside CSS selectors " background: url('tcm:x-yy') ", publishes the MMC and replaces the reference with the resolved URL. I got this TBB from my colleague Eric Huiza , so he gets the credit for it ;) Name Render Css Images In Output TBB Type ·     Template in .NET Assembly Description Used to: ·     Resolve references to Multimedia Components TcmUris inside CSS syntax; ·     Publish the MMC and replace the TcmUri reference with the resolved URL; Notes: This generic TBB uses the Output item to search for references to MMC TcmUris (or WebDav URLs) inside CSS ‘ background ’ selectors. If such MMC TcmUri is identified, the MMC is published (to the mapped Structure Group) and the returned URL replaces the TcmUri reference. The Output item is rewritten with the reso...

Event System to Create Mapped Structure Groups for Binary Publish

As a continuation of last week's Publish Binaries to Mapped Structure Group , this week's TBB is in fact the Event System part of that solution. Make sure you do check out the previous post first, which explains why and what this Event System does. To reiterate, the Event System intercepts a Multimedia Component save, take its Folder path and create a 1-to-1 mapping of Structure Groups. The original code was written, again, by my colleague Eric Huiza : [ TcmExtension ( "MyEvents" )] public class EventsManager  : TcmExtension {     private Configuration configuration;     private readonly Regex SAFE_DIRNAME_REGEX = new Regex ( @"[\W_]+" );     public EventsManager() {         ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap ();         fileMap.ExeConfigFilename = Path .GetDirectoryName( Assembly .GetExecutingAssembly().Loc...