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

Toolkit - Dynamic Content Queries

This post if part of a series about the  File System Toolkit  - a custom content delivery API for SDL Tridion. This post presents the Dynamic Content Query capability. The requirements for the Toolkit API are that it should be able to provide CustomMeta queries, pagination, and sorting -- all on the file system, without the use third party tools (database, search engines, indexers, etc). Therefore I had to implement a simple database engine and indexer -- which is described in more detail in post Writing My Own Database Engine . The querying logic does not make use of cache. This means the query logic is executed every time. When models are requested, the models are however retrieved using the ModelFactory and those are cached. Query Class This is the main class for dynamic content queries. It is the entry point into the execution logic of a query. The class takes as parameter a Criterion (presented below) which triggers the execution of query in all sub-criteria of a Criterio

A DD4T.net Implementation - Custom Binary Publisher

The default way to publish binaries in DD4T is implemented in class DD4T.Templates.Base.Utils.BinaryPublisher and uses method RenderedItem.AddBinary(Component) . This produces binaries that have their TCM URI as suffix in their filename. In my recent project, we had a requirement that binary file names should be clean (without the TCM URI suffix). Therefore, it was time to modify the way DD4T was publishing binaries. The method in charge with publishing binaries is called PublishItem and is defined in class BinaryPublisher . I therefore extended the BinaryPublisher and overrode method PublishItem. public class CustomBinaryPublisher : BinaryPublisher { private Template currentTemplate; private TcmUri structureGroupUri; In its simplest form, method PublishItem just takes the item and passes it to the AddBinary. In order to accomplish the requirement, we must specify a filename while publishing. This is the file name part of the binary path of Component.BinaryConten

Scaling Policies

This post is part of a bigger topic Autoscaling Publishers in AWS . In a previous post we talked about the Auto Scaling Groups , but we didn't go into details on the Scaling Policies. This is the purpose of this blog post. As defined earlier, the Scaling Policies define the rules according to which the group size is increased or decreased. These rules are based on instance metrics (e.g. CPU), CloudWatch custom metrics, or even CloudWatch alarms and their states and values. We defined a Scaling Policy with Steps, called 'increase_group_size', which is triggered first by the CloudWatch Alarm 'Publish_Alarm' defined earlier. Also depending on the size of the monitored CloudWatch custom metric 'Waiting for Publish', the Scaling Policy with Steps can add a difference number of instances to the group. The scaling policy sets the number of instances in group to 1 if there are between 1000 and 2000 items Waiting for Publish in the queue. It also sets the