Thursday, July 23, 2015

Oracle ATG Controller Framework


  •  Introduction to Servlet Pipeline

            Oracle ATG Controller Framework is used to handle how HTTP requests are processed. Basically, It performs tasks like session tracking, page compilation etc. Controller includes series of separable servlets which has its own individual task, so called as Servlet Pipeline.
    This series of steps is dependent very much on sequence in which servlets are placed because of the information flow of request. Each servlet processes the request and may have input to next servlet.
    • Request Processing by Servlet Pipeline

    While processing a request in ATG, every step or task is a Nucleus component which implements Servlet interface. It is organized in linked list kind of data structure and is called a request-handling pipeline.
    Whenever request comes to the pipeline it is handled by the pipeline in a component oriented manner i.e. by having servlets as independent elements.
    ATG Provides Out of the Box pipeline to handle request which is used to process each request to application. It is started by a Page filter and requests which are coming to Nucleus are dispatched to PageFilter or DynamoProxyServlet. And it then follows the order of servlets in series.
    Here, each of these servlets perform their function on the request. Also, servlet is configured with a reference to the next servlet in pipeline. So, when a first servlet is processed on the request, it will pass the request to the next servlet and so on.
    ATG also provides flexibility of customizing the pipeline through components. These components are configurable and use Out of the Box provisions to execute in sequential manner.

    Below is the example of ATG Out of the Box Pipeline.

    • Example with Out of the Box Pipeline
      Dynamo Servlet Pipeline
    • How to customize Servlet Pipeline
    Every servlet in pipeline implement atg.servlet.pipeline.PipelineableServlet interface. 
    When we implement PipelineableServlet, it inherits a nextServlet property. This property is used to point to the next servlet component to invoke. 
    The pipeline components created should be scoped as global. Also, they need to be configured into pipeline.
    PipelineableServlet interface has two subinterfaces.  These two types provide additional features for determining the next component to invoke.
    1. InsertableServlet 

    This interface has a property called insertAfterServlet to enable the servlet to insert itself in a specific position in the pipeline. This mechanism is useful when you donot want to change or modify existing pipeline configurations and insert silently.
    Example: MyApp.java

    package com.myapp;

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import atg.servlet.*;
    import atg.servlet.pipeline.*;
    public class MyServllet extends InsertableServletImpl {

    public MyServlet () {}

    public void service (DynamoHttpServletRequest request,DynamoHttpServletResponse response)throws IOException, ServletException {
    System.out.println ("Inside MyServlet with request " +request.getRequestURI ());
    passRequest (request, response);
    }
    }

    MyServlet.properties
    $class=com.myapp.MyServlet
    insertAfterServlet=/atg/dynamo/servlet/pipeline/DynamoServlet

    Here, MyServlet will be inserted after DynamoServlet


    2. DispatcherPipelineableServlet 

    This interface provide a mechanism to create branches of servlets using some condition.
    It is possible with dispatcherServiceMap property of this class, which is a map of servlets based on condition.
    Out of the box MimeTypeDispatcher servlet is used to determine which servlet needs to be invoked based on the MIME type of the request.

    Tuesday, July 14, 2015

    BCC 11.1 Customization: Adding New item descriptor

    Whenever you create a new item descriptor or a repository which can be modified by Merchandiser, it should be present in BCC in order to add, modify and delete items.

    As part of ATG 11.1 version, Oracle has provided simple steps to view newly created item-descriptor in BCC Flex UI.

    Let us assume, we have created new item descriptor called contentItem in /atg/commerce/catalog/ProductCatalog repository.
    (Modified /config/atg/commerce/catalog/custom/customCatalog.xml).

    To add a new content item in BCC 11.1 follow below steps :

    1. Adding to Content Browse Hierarchy

    Location:    <your_module>\config\atg\remote\content\browse\ContentBrowseHierarchy.xml

    This will be used to view your item in content browser.

    Add below code for contentItem

    <?xml version="1.0" encoding="ISO-8859-1" ?>

    <browse-hierarchy xml-combine="append">

      <browse-item id="home" xml-combine="append">

        <browse-item reference-id="contentItemDetails"/>
      </browse-item>

    <browse-item id="contentItemDetails" label-resource="node.styles.label.contentItem"  is-root="true" >
        <list-definition id="contentItemDetailsId" retriever="query" child-type="/atg/commerce/catalog/ProductCatalog:contentItem">
    <retriever-parameter name="query"  value="ALL" />
        </list-definition>
      </browse-item>

    </browse-hierarchy>

    Here, node.styles.label.contentItem is an property for Label to display in BCC.

    You need to create new properties file in your source directory say, com.yourapp.web.resources.RepositoryTemplateResources.properties

    To Configure this properties file as resource bundle referred by BCC, create a file below with same name and path:
    <your_module>\config\atg\remote\assetmanager\MultiBundleFormatter.properties

    and provide contents as:

    bundlePaths+=\
         com.yourapp.web.resources.RepositoryTemplateResources

    You may add any number of resource bundle values in this property file. But, it is best practice to create separate file for each repository, so that it can be managed separately.

    2. Adding to Content Find Configuration

    Location: <your_module>\config\atg\remote\content\find\ContentFindConfiguration.xml

    This will be used to display newly create item-descriptor in find tab.

    Add below contents in xml file for find configuration;

    <?xml version="1.0" encoding="UTF-8"?>

    <find-configuration site-filtering="true" xml-combine="append">

    <asset-family id="contentItem" site-filtering="false">
        <display-name>Content Item</display-name>
        <enable-default-query>true</enable-default-query>
        <enable-filter-as-you-type>true</enable-filter-as-you-type>
        <result-list page-size="500"/>
        <default-asset-type>contentItem</default-asset-type>
        <asset-type  id="finish" site-filtering="false">
          <enable-default-query>true</enable-default-query>
          <enable-filter-as-you-type>true</enable-filter-as-you-type>
          <repository-path>/atg/commerce/catalog/ProductCatalog</repository-path>
          <repository-item-type>contentItem</repository-item-type>
        </asset-type>
    </asset-family>

     </find-configuration>

    3. Add to Content Tool bar

    Location: <your_module>\config\atg\remote\content\toolbar\ContentToolbar.xml

    This will be used to display control buttons in toolbar while you are navigating through browse item.
    Buttons like add, edit, delete, move, duplicate etc. can be controlled through this xml.

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <toolbar xml-combine="append">

    <operation-menu id="contentItemMenu">
    <toolbar-scope asset-area="contentItem" pane-id="browse"/>
    <operation-menu-item id="edit" />
    <operation-menu-item id="move"/>
    <operation-menu-item divider="true" />
    <operation-menu-item id="duplicate" />
    <operation-menu-item id="delete" />
    <operation-menu-item divider="true" />
    <operation-menu-item id="addToProject" />
    <operation-menu-item id="export" />
    </operation-menu>

    </toolbar>



    ATG 11.0 Installation with Cim, MySql, Jboss and Endeca

    Prerequisites:
    1. ATG11.0 and Endeca Installed on system
    2. MySQL service is running with default Databases created
    3. JBoss6.1 is downloaded and extracted

    Click on below link to get the doc:

    https://drive.google.com/file/d/0BxgfTUo4XwVBWXhpbG51UnUxX28/view?usp=sharing