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.
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:
5. Edit file cd_storage_conf.xml. Add the following lines after the opening tag <Storages>
6. Restart the Deployer
1. In your web-application /lib folder, copy files:
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:
At this moment, the Toolkit API can be executed in the web-application.
Add a logger on classes under com.mitza package and the logging will be output.
Sample logback.xml that outputs to console:
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:
4. Edit file cd_deployer_conf.xml. Add the following lines before the end tag </Processors>- 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;
<!-- 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
- 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;
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