Skip to main content

Toolkit - Installation and Configuration

This post if part of a series about the File System Toolkit - a custom content delivery API for SDL Tridion.

The File System Toolkit consists of two parts: a Deployer extension and the Content Delivery API itself. This post describes installing and configuring both.

Toolkit JARs are available under the GitHub repository of the File System Toolkit project, in folder /distributable. Alternatively, you can build your JARs using the sources available on GitHub.

Toolkit Deployer Installation

This deployer extension handles the creation of JSON files on the file system. The Toolkit CD API then reads these JSON files and creates model objects from them.

In order to obtain these JSON files, a deployer extension must be installed on top of a functional Tridion Content Delivery Deployer. The Toolkit deployer extension works for both file system-based or database-based Tridion Deployers.

1. In the Tridion Deployer /lib folder, copy files:
  • toolkit-api.jar
  • toolkit-deployer.jar
  • toolkit-model.jar
2. Also to folder /lib, copy files:
  • ehcache-2.8.3.jar
  • jackson-annotations-2.6.4.jar
  • jackson-core-2.6.4.jar
  • jackson-databind-2.6.4.jar
  • logback-classic.jar
  • logback-core.jar
  • slfj-api.jar
3. Edit or create if it doesn't exist, file toolkit.properties and place it in the class-path of the Deployer (/WEB-INF/classes for an HTTP deployer). The following properties are relevant for deployer extension:
  • cacheEnabled - boolean whether to use cache or not;
  • cacheMaxEntriesLocalHeap - integer the size of the cache;
  • cacheMonitorSeconds - integer the interval in seconds to perform cache stale checks;
  • cacheTimeToLiveSeconds - integer the number of seconds to keep an item in cache;
  • cacheTimeToIdleSeconds - integer the number of seconds to keep an idle item in cache;
  • cleanup - boolean whether to delete empty directories after unpublish;
  • contentRoot - string the path where the published Tridion pages are published (this path is defined in cd_storage_conf.xml);
  • jsonRoot - string the path where the JSON files are stored under;
  • prettyPrintJson - boolean whether to space indent JSON files for better human-reading or not;
4. Edit file cd_deployer_conf.xml. Add the following lines before the end tag </Processors>

<!-- Toolkit JSon Modules -->
<Processor Action="Deploy" Phase="post-transaction" Class="com.tridion.deployer.Processor">
    <Module Type="PageDeploy" Class="com.mitza.toolkit.deployer.JSonPageDeploy"/>
    <Module Type="ComponentDeploy" Class="com.mitza.toolkit.deployer.JSonComponentDeploy"/>
    <Module Type="ComponentPresentationDeploy"
            Class="com.mitza.toolkit.deployer.JSonComponentPresentationDeploy"/>
    <Module Type="BinaryDeploy" Class="com.mitza.toolkit.deployer.JSonBinaryDeploy"/>
</Processor>

<Processor Action="Undeploy" Phase="post-transaction" Class="com.tridion.deployer.Processor">
    <Module Type="PageUndeploy" Class="com.mitza.toolkit.deployer.JSonPageUndeploy"/>
    <Module Type="ComponentPresentationUndeploy"
            Class="com.mitza.toolkit.deployer.JSonComponentPresentationUndeploy"/>
</Processor>
<!-- End of Toolkit JSon Modules -->

5. Edit file cd_storage_conf.xml. Add the following lines after the opening tag <Storages>

<StorageBindings>
    <Bundle src="toolkit_dao_bundle.xml"/>
</StorageBindings>

6. Restart the Deployer

Toolkit API Installation

The Toolkit is an API to be used in your web-application as middle-tier to retrieve content published from SDL Tridion. The installation implies copying the JARs and configuration files to folders available in the class-path of your web-application:

1. In your web-application /lib folder, copy files:
  • toolkit-api.jar
  • toolkit-dynamic.jar
  • toolkit-model.jar
2. Also to folder /lib, copy files:
  • ehcache-2.8.3.jar 
  • jackson-annotations-2.6.4.jar 
  • jackson-core-2.6.4.jar 
  • jackson-databind-2.6.4.jar 
  • logback-classic.jar 
  • logback-core.jar 
  • slfj-api.jar 
3. Edit or create if it doesn't exist, file toolkit.properties and place it in folder /WEB-INF/classes. The following properties are relevant:
  • cacheEnabled - boolean whether to use cache or not;
  • cacheMaxEntriesLocalHeap - integer the size of the cache;
  • cacheMonitorSeconds - integer the interval in seconds to perform cache stale checks;
  • cacheTimeToLiveSeconds - integer the number of seconds to keep an item in cache;
  • cacheTimeToIdleSeconds - integer the number of seconds to keep an idle item in cache;
  • contentRoot - string the path where the published Tridion pages are published (this path is defined in cd_storage_conf.xml);
  • jsonRoot - string the path where the JSON files are stored under;
In case dynamic tags are used, they can be configured using properties tag.name.X and tag.class.X. These tags define the tag name and tag fully qualified class name to be executed when the given tag name is encountered in the Component Presentation content. The X stands for a 1-based counter that allows us to define several tags by simply incrementing the counter.

Example:
The following definition of tags defines 2 tags. First with name mytag backed by class com.mitza.toolkit.tag.MyTag and the second with name yourtag and backed by class com.mitza.toolkit.tag.SecondTag:

tag.name.1=mytag
tag.class.1=com.mitza.toolkit.tag.MyTag
tag.name.2=yourtag
tag.class.2=com.mitza.toolkit.tag.SecondTag

At this moment, the Toolkit API can be executed in the web-application.

Logging

The Toolkit uses logback API. This can be configured in a logback.xml file in the web-application class-path (typically in WEB-INF/classes folder).

Add a logger on classes under com.mitza package and the logging will be output.

Sample logback.xml that outputs to console:

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
    <property name="log.pattern" value="%date [%thread] %5p %c{1} - %m%n"/>
    <property name="log.level" value="info"/>

    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>

    <logger name="com.mitza" level="${log.level}"/>

    <root level="OFF">
        <appender-ref ref="STDOUT"/>
    </root>
</configuration>



Comments

Popular posts from this blog

Running sp_updatestats on AWS RDS database

Part of the maintenance tasks that I perform on a MSSQL Content Manager database is to run stored procedure sp_updatestats . exec sp_updatestats However, that is not supported on an AWS RDS instance. The error message below indicates that only the sa  account can perform this: Msg 15247 , Level 16 , State 1 , Procedure sp_updatestats, Line 15 [Batch Start Line 0 ] User does not have permission to perform this action. Instead there are several posts that suggest using UPDATE STATISTICS instead: https://dba.stackexchange.com/questions/145982/sp-updatestats-vs-update-statistics I stumbled upon the following post from 2008 (!!!), https://social.msdn.microsoft.com/Forums/sqlserver/en-US/186e3db0-fe37-4c31-b017-8e7c24d19697/spupdatestats-fails-to-run-with-permission-error-under-dbopriveleged-user , which describes a way to wrap the call to sp_updatestats and execute it under a different user: create procedure dbo.sp_updstats with execute as 'dbo' as...

REL Standard Tag Library

The RSTL is a library of REL tags providing standard functionality such as iterating collections, conditionals, imports, assignments, XML XSLT transformations, formatting dates, etc. RSTL distributable is available on my Google Code page under  REL Standard Tag Library . Always use the latest JAR . This post describes each RSTL tag in the library explaining its functionality, attributes and providing examples. For understanding the way expressions are evaluated, please read my post about the  Expression Language used by REL Standard Tag Library . <c:choose> / <c:when> / <c:otherwise> Syntax:     <c:choose>         <c:when test="expr1">             Do something         </c:when>         <c:when test="expr2">             Do something else         </c:when...

Publish Binaries to Mapped Structure Groups

Today's TBB of the Week comes from the high demand in the field to publish binary assets to different mapped Structure Groups. By default SDL Tridion offers two ways of publishing binaries: All binaries publish to a folder defined in your Publication properties; All binaries rendered by a given template publish to a folder corresponding to a given Structure Group; In my view, both cases are terrible, over-simplified and not representing a real use-case. Nobody in the field wants all binaries in one folder and nobody separates binary locations by template. Instead, everybody wants a mapping mechanism that takes a binary and publishes it to a given folder, defined by a Structure Group, and this mapping is done using some kind of metadata. More often than not, the metadata is the TCM Folder location of the Multimedia Component. I have seen this implemented numerous times. So the solution to publish binaries to a given location implies finding a mapping from a TCM Folder to a...