Showing posts with label Tridion 2013. Show all posts
Showing posts with label Tridion 2013. Show all posts

Monday, 23 May 2016

MongoDB Integration 4 Tridion-Mi4T

Introduction

MongoDB Integration 4 Tridion-Mi4T is intent to provide the Tridion integration with MongoDB

Let's see some of the features advantages of using MongoDB

Advantages
  1. Schema less : MongoDB is document database in which one collection holds different different documents. Number of fields, content and size of the document can be differ from one document to another.
  2. Structure of a single object is clear
  3. Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language
Why should use MongoDB
  1. Document Oriented Storage : Data is stored in the form of JSON style documents
  2. Index on any attribute
  3. Replication & High Availability
  4. Rich Queries
Where should use MongoDB?
  1. Big Data
  2. Content Management and Delivery
  3. Mobile and Social Infrastructure
  4. User Data Management

How to Set-up and Configure Mi4T

We have five different modules in the Mi4T
  1. MongoDB - Setup and configuration
  2. Template Bulding Block:- C# TBB is used to get the component DCP in XMLformat after some changes . 
  3. Custom Storage Extension – A JPAComponentPresentationDAO based custom storage extension to manipulate the dynamic component presentations
  4. MongoDBIndexService- WCFRestFul Service which get invoked by custom storage extension and take DCP as input
  5. MongoDBSearchService - WCFRestFul service to get the data from MongoDB and take input query in JSON format .

SETUP

Below are various setup steps
  1. CMS Setup
    • Copy and paste the templating building block (TBB) to a location on your Tridion CM Server 
    • Upload MI4TIndexing.Templating.dll TBB to Tridion CMS 
    • Create a Component Template with following attributes
      • Output Format – XML Fragment
      • Add GetComponentAsXML TBB ,Publish Binaries in Package, Link Resolver and Cleanup Template 
  2. MongoDB Setup
  3. Content Delivery Setup
    • Open the cd_storage_config.xml Storage Configuration file from the /bin/config folder and add following node under the Storages section:
      • <StorageBindings><Bundle src="CustomStorageDAOBundles.xml"/></StorageBindings>
    • Copy and paste CustomStorageConfig.xml file to change the value of following nodes
      • ServiceEndPoint - URL of the IndexService
      • TemplateIdToIndex - Tcm Id Of component Template which we have created in step 1 CMS setup. 
    • Copy the CustomStorageDAOBundles.xml XML file in the Content Delivery /bin/config folder
  4. MongoDB Index Service
    • Copy and paste MongoDBIndexService on your server host it in IIS 
    • Copy the configuration folder as well .
      • You can update the log files path from Logging.config inside the configuration folder
    • Update the path of configuration\logging.config file in web.config of index service
  5. MongoDB Search Service
    • Copy and paste MongoDBIndexService on your server host it in IIS 
    • Copy the configuration folder as well 
      • Update the log files path in Logging.config inside the configuration folder
    • Update the path of configuration\logging.config file in web.config of index service
  6. Index service support Publishing ,Re-publishing and un-publishing
  7. Search service will get the data in JSON format. 

To test the index and search services

  1. Index service

    1. You can use fiddler for debugging 
    2. I have created a sample schema article
      1. title
      2. description
      3. imageurl
    3. Run index service on fiddler
      • http://localhost/Service1.svc/AddDocument
      • Input JSON which will generated by custom storage 
      • {"ServicePayload":{"DCP":"<Content xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:tcm='http://www.tridion.com/ContentManager/5.0' Title='Copy of Demo Of MongoDB' Id='tcm:2073-13667'><title>Demo Of MongoDB</title><description><![CDATA[Demo of component creation in Tridion using MongoDB]]></description><imageurl>/images/demo.png</imageurl><publication Id='tcm:0-2073-1' Title='03 Content Master' /></Content>","LanguageInRequest":"en"}} 
    4. Execute this request in Fidler and verify the results returned
    5. Check in mongoDB as well inside the collection\document which you have created and entered in the index service 
    6. Result as 0 for success and 1 for failure
      •  {"ResponseContext":{"EnvironmentContext":null,"FaultCollection":[]},"ServicePayload":{"ErrorMessage":"","Result":0}}
    7. Test this by publishing the Component as well 
    8. Log File Where Response Result :0 means successfully published and data is index in MongoDB
  1. Search Service
    1. You use the fiddler for debugging 
    2. Run the search service on fiddler
      • Url:- http://localhost/SearchSvc.svc/GetContentFromMongoDB
      • {"ServicePayload":{"ContentType":"Content","Filters":[{"Key":"ItemURI","Value":"tcm:2073-13667"},{"Key":"publicationID","Value":"tcm:0-2073-1"}]}
      • Execute the request in fiddler and verify the results returned
      • This service will get you the result based on Filters you provide and  use //MAP/REDUCE  
      •  //Map/Reduce            
                            var map =
                                "function() {" +
                                "    for (var key in this) {" +
                                "        emit(key, { count : 1 });" +
                                "    }" +
                                "}";

                            var reduce =
                                "function(key, emits) {" +
                                "    total = 0;" +
                                "    for (var i in emits) {" +
                                "        total += emits[i].count;" +
                                "    }" +
                                "    return { count : total };" +
                                "}";
      • Output will be in the JSON format 
      • { "_id" : ObjectId("5741539eef525465db9eb131"), "title" : "Demo Of MongoDB", "description" : "Demo of component creation in Tridion using MongoDB", "imageUrl" : "/images/demo.png", "ItemURI" : 
      •  
      • "tcm:2073-13667", "publicationID" : "tcm:0-2073-1" }
      • You can have AND,OR and NOT as a logical operators to query the data from MongoDB
        • {"ServicePayload":{"ContentType":"Content","Filters":[{"Key":"ItemURI","Value":"tcm:278-13667"},{"Key":"publicationID","Value":"tcm:0-278-1"}],"MongoDatabase":"customerDatabase","Table":"article","QueryType":"OR"}
  2. You can download the code here

Happy Coding & Keep Sharing !!!

MongoDB Integration 4 Tridion-Mi4T

Introduction

MongoDB Integration 4 Tridion-Mi4T is intent to provide the Tridion integration with MongoDB

Let's see some of the features advantages of using MongoDB

Advantages
  1. Schema less : MongoDB is document database in which one collection holds different different documents. Number of fields, content and size of the document can be differ from one document to another.
  2. Structure of a single object is clear
  3. Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language
Why should use MongoDB
  1. Document Oriented Storage : Data is stored in the form of JSON style documents
  2. Index on any attribute
  3. Replication & High Availability
  4. Rich Queries
Where should use MongoDB?
  1. Big Data
  2. Content Management and Delivery
  3. Mobile and Social Infrastructure
  4. User Data Management

How to Set-up and Configure Mi4T

We have five different modules in the Mi4T
  1. MongoDB - Setup and configuration
  2. Template Bulding Block:- C# TBB is used to get the component DCP in XMLformat after some changes . 
  3. Custom Storage Extension – A JPAComponentPresentationDAO based custom storage extension to manipulate the dynamic component presentations
  4. MongoDBIndexService- WCFRestFul Service which get invoked by custom storage extension and take DCP as input
  5. MongoDBSearchService - WCFRestFul service to get the data from MongoDB and take input query in JSON format .

SETUP

Below are various setup steps
  1. CMS Setup
    • Copy and paste the templating building block (TBB) to a location on your Tridion CM Server 
    • Upload MI4TIndexing.Templating.dll TBB to Tridion CMS 
    • Create a Component Template with following attributes
      • Output Format – XML Fragment
      • Add GetComponentAsXML TBB ,Publish Binaries in Package, Link Resolver and Cleanup Template 
  2. MongoDB Setup
  3. Content Delivery Setup
    • Open the cd_storage_config.xml Storage Configuration file from the /bin/config folder and add following node under the Storages section:
      • <StorageBindings><Bundle src="CustomStorageDAOBundles.xml"/></StorageBindings>
    • Copy and paste CustomStorageConfig.xml file to change the value of following nodes
      • ServiceEndPoint - URL of the IndexService
      • TemplateIdToIndex - Tcm Id Of component Template which we have created in step 1 CMS setup. 
    • Copy the CustomStorageDAOBundles.xml XML file in the Content Delivery /bin/config folder
  4. MongoDB Index Service
    • Copy and paste MongoDBIndexService on your server host it in IIS 
    • Copy the configuration folder as well .
      • You can update the log files path from Logging.config inside the configuration folder
    • Update the path of configuration\logging.config file in web.config of index service
  5. MongoDB Search Service
    • Copy and paste MongoDBIndexService on your server host it in IIS 
    • Copy the configuration folder as well 
      • Update the log files path in Logging.config inside the configuration folder
    • Update the path of configuration\logging.config file in web.config of index service
  6. Index service support Publishing ,Re-publishing and un-publishing
  7. Search service will get the data in JSON format. 

To test the index and search services

  1. Index service

    1. You can use fiddler for debugging 
    2. I have created a sample schema article
      1. title
      2. description
      3. imageurl
    3. Run index service on fiddler
      • http://localhost/Service1.svc/AddDocument
      • Input JSON which will generated by custom storage 
      • {"ServicePayload":{"DCP":"<Content xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:tcm='http://www.tridion.com/ContentManager/5.0' Title='Copy of Demo Of MongoDB' Id='tcm:2073-13667'><title>Demo Of MongoDB</title><description><![CDATA[Demo of component creation in Tridion using MongoDB]]></description><imageurl>/images/demo.png</imageurl><publication Id='tcm:0-2073-1' Title='03 Content Master' /></Content>","LanguageInRequest":"en"}} 
    4. Execute this request in Fidler and verify the results returned
    5. Check in mongoDB as well inside the collection\document which you have created and entered in the index service 
    6. Result as 0 for success and 1 for failure
      •  {"ResponseContext":{"EnvironmentContext":null,"FaultCollection":[]},"ServicePayload":{"ErrorMessage":"","Result":0}}
    7. Test this by publishing the Component as well 
    8. Log File Where Response Result :0 means successfully published and data is index in MongoDB
  1. Search Service
    1. You use the fiddler for debugging 
    2. Run the search service on fiddler
      • Url:- http://localhost/SearchSvc.svc/GetContentFromMongoDB
      • {"ServicePayload":{"ContentType":"Content","Filters":[{"Key":"ItemURI","Value":"tcm:2073-13667"},{"Key":"publicationID","Value":"tcm:0-2073-1"}]}
      • Execute the request in fiddler and verify the results returned
      • This service will get you the result based on Filters you provide and  use //MAP/REDUCE  
      •  //Map/Reduce            
                            var map =
                                "function() {" +
                                "    for (var key in this) {" +
                                "        emit(key, { count : 1 });" +
                                "    }" +
                                "}";

                            var reduce =
                                "function(key, emits) {" +
                                "    total = 0;" +
                                "    for (var i in emits) {" +
                                "        total += emits[i].count;" +
                                "    }" +
                                "    return { count : total };" +
                                "}";
      • Output will be in the JSON format 
      • { "_id" : ObjectId("5741539eef525465db9eb131"), "title" : "Demo Of MongoDB", "description" : "Demo of component creation in Tridion using MongoDB", "imageUrl" : "/images/demo.png", "ItemURI" : 
      • "tcm:2073-13667", "publicationID" : "tcm:0-2073-1" }
      • You can have AND,OR and NOT as a logical operators to query the data from MongoDB
        • {"ServicePayload":{"ContentType":"Content","Filters":[{"Key":"ItemURI","Value":"tcm:278-13667"},{"Key":"publicationID","Value":"tcm:0-278-1"}],"MongoDatabase":"customerDatabase","Table":"article","QueryType":"OR"}
  2. You can download the code here

Happy Coding & Keep Sharing !!!

Monday, 16 May 2016

Creating Components in SDL Tridion using MongoDB Data Feed

In one of my previuos post we've discussed how to create components in SDL Tridion using MSSQLServer as a DataSoucre but today we are going to create components in SDL Tridion using MongoDB as a DataSource


We are going to use SDL Tridion CoreService,MonoDB 3.2.6 ssl-signed and C# as a language

You can download MongoDB from here and to know more about MongoDB here

Create an empty solution

  1. MongoDb.Client
    • C# Console Based Application Running on .NET 4.5
    • which will get the data from mongoDB
  2. MongoDBToTridion.BAL
    • In this Class Liabrary  i have written all the logic in order to create component.
  3. Install MongoDB Drivers
    • Install-Package MongoDB.Driver
  4. Create SDL Tridion CoreService Client
    • ISessionAwareCoreService
  5. Create a model name Article as Serializable
  6. I have also create a Database called customerDatabase in MongoDB
  7. In my customerDatabase i have create document name article which we will use to create component
  8. Main Method which is starting point of this application 

     
      9.Update appsettings key in app.config file 


     10. Process List<Article>


   11.Serialize article model


  12.Create or update Component in Tridion 


 Compare your Data in MongoDB with components created in Tridion


All the data which are available in Article Document in MongoDB has been successfully  created as Components in Tridion .



Open Component and check 



You can download the code from here


Happy Coding and keep Sharing !!!!

Friday, 29 April 2016

WCF RestService over CoreService

WCF RestService over CoreService 

Introduction 

This service is created to get data from SDL Tridion CM Database ,currently this service is tested with SDL Tridion 2013 SP1


In this service you will see many methods are exposed and message format JSON and XML output.

Methods which are available
  1. GetComponentByTcmUri
  2. GetSchemaByTcmUri
  3. GetAllCategoriesWithInPubByTcmUri
  4. GetKeywordByCategoryID
  5. GetPageTempletByPubID
  6. GetComponentTemplateByPubID
  7. GetTemplateBuildingBlockByPubID
  8. GetPageByPubID
  9. GetStructureGroupByPubID
  10. GetMultimediaComponentByPubID
  11. GetPublicationList
  12. GetUserList 


Example
To request a categories from the Tridion CM Database.
http://domainname/RestService.svc/GetAllCategoriesWithInPubByTcmUri/{TCMURI}/{messageformat}
http://domainname/RestService.svc/GetAllCategoriesWithInPubByTcmUri/0-1048-1/JSON

You can download the code from here

Happy coding and keep sharing :)

Thursday, 28 April 2016

SDL Tridion 2013 SP1 SmartTarget With Fredhopper on Windows Machine

Fredhopper: SDL Fredhopper is a Customer Experience Management tool which provides a seamless, targeted and fully personalized website experience to the end users. The SDL Fredhopper enables the marketing team to target a specific segment of customer with all the right products or content which suits them best.

SmartTarget: SmartTarget is an add-on for SDL Tridion which integrates SDL Tridion with SDL Fredhopper. SmartTarget acts as a bridge between SDL Tridion and SDL Fredhopper so that Marketers can create, update and manage targeted and personalized content for SDL Tridion driven website.

1      configure fredhopper


 The document is developed for SDL Tridion 2013 SP1, smart target 2014 and fredhopper-7.5-revision-13.You first need to configure fredhopper. Assuming Odata Services and CD is already confirmed.

·         extract fredhopper-7.5-revision-13 in C :

      To download Fredhopper Link you would required valid credentials to login 


·         follow below command to configure the fredhopper

·         You need designated service account with username fredhopper  to configure fredhopper

·         ..\fredhopper\config Create a topology.txt in your Fredhopper config folder
                   # The topology file defines your indexing and live servers
                   # instance name | host | preset | indexer | comment
                      SmartTarget|localhost|1|-|Indexer and Preview environment for demo setup                                           SmartTargetLive|localhost|2|SmartTarget|Live Query Server for demo setup

       Where:
     SmartTarget is the Indexer Server (for getting content into Fredhopper)
                SmartTargetLive is the Query Server (for getting content out of Fredhopper)

1.       Open command prompt cmd /admin and execute the below commands in sequence always in new window.
o    bin\deployment-agent
 
o    bin\setup-cluster

  1. In the ..\fredhopper\data\instances\SmartTarget folder, create a folder \custom.
3.  Copy configuration-management-rest-extension.jar and smarttarget_api_extension.jar to the \custom folder. 
4.  In the  ..\fredhopper\SmartTarget\data\fas-xml-incremental folder, create a folder \catalog01
And Copy the metadata.xml file to the \catalog01 folder. 
5.  Copy the trigger-types.xml and business.xml to C:\fredhopper\data\instances\SmartTarget\config folder. 
6.  Copy the STJob.kjb file to the ..\fredhopper\data\instances\etl folder. 
7.  Start up the SmartTarget or SmartTargetLive instance using the command:
8.  Execute below commands
o    bin\instance SmartTarget start

o    bin\deployment-agent-client –location localhost invoke SmartTarget qserver stop
o    bin\deployment-agent-client –location localhost invoke SmartTarget qserver start

o    bin\run-etl-job STjob.kjb “-DINSTANCE=SmartTarget” “-DTRIGGER=load-data”
 “-DUNIVERSE=catalog01” “-DEXECUTIONPATH=C:/fredhopper/data/instances/SmartTarget/custom”

           9.       Browse to the Fredhopper Business Manager:
     10. http://localhost:8180/fredhopper/admin/ 
   
          11.   Use the credentials admin/admin to log on. (The Business Manager connects to the Indexer Server.)
    
      

      2.Steps for Smart Target static implementation:

Install SmartTarget 2014 available in installation media

Click On Targeting Option







1   .      Create PT for page
1.1.  Add Extract Components from Page tbb.
1.2. Create DWT(Suppose name as ST Region DWT) having content as
<tcdl:region id="Sidebar" type="SmartTarget">

</tcdl:region>

1.3.  Default Finish Actions
1.4.  Open Template Building Block to create PT for page(Suppose name as Smart Target PT)
1.5.  Drag DWT “ST Region DWT” to PT “Smart Target PT”
1.6.  Add SmartTarget Query tbb
1.7.  Add Promotions tbb
1.8.  Add Show SmartTarget Navigation tbb
1.9.  Add Search SmartTarget tbb
1.10.Add Show SmartTarget Items tbb
1.11.Add Apply SmartTarget Settings tbb
1.12. Configure parameter values of above tbbs
1.13.Run PT with page and check if it is working fine

2  .      Create dynamic CT for promotion component
Create a dynamic Component Template (Suppose SendContentToFredhopper) in Template Builder which uses the “Add to SmartTarget” Template Building Block to send content to Fredhopper.
2.1. Add Default DreamWeaver Component Design DWT
2.2.  Add “Add to SmartTarget” tbb
2.3.  Add Default finish action tbb
2.4.  Save and close CT.
2.5.  Add your promotion component schema(Suppose Promotion) as a linked schema

3  .      Create promotion component
Create a component (Suppose “ST Promotion”) with schema “Promotion”.

4  .      Create Promotion
Create a promotion by going to Targeting Tab of CME. Use Trigger as current date.

5  .      Create page
Create a page using PT “Smart Target PT” having component “ST Promotion” and CT “SendContentToFredhopper”.



Execute your Page

Happy Coding and Keep sharing :)

WCF RestService over Broker API

Introduction 

This service is created to get data from SDL Tridion Broker Database using broker API ,currently this service is tested with SDL Tridion 2013 SP1  


In this service you will see many methods are exposed and message format JSON and XML output.

Methods which are available

  1. Get Components by SchemaID
  2. Get Page by URL
  3. Get Page by TcmId 
  4. Get ComponentPresentation By TcmId
  5. Get multipleComponentPresentation By TcmId 
  6. Get ComponentPresentation By PublishedDate
  7. Get ComponentPresentation By SchemaID







Example
To request a page from the Tridion broker.
http://domainname/Tridion2013SP1Provider.svc/GetPagebyUrl/{publicationId}/{format}?url={url} 
http://domainname/Tridion2013SP1Provider.svc/GetPagebyUrl/2073/xml?url=/Collection/index.aspx

You can download the code from here

Happy coding and keep sharing :)