Showing posts with label Core ATG. Show all posts
Showing posts with label Core ATG. Show all posts

Logger Mechanism in ATG

Types of log message:
  1. error
  2. warning
  3. info
  4. debug (Disabled)
  • atg.nucleus.GenericService is the ATG class which provides logging feature by default
  • Default error, warning and info is enabled
  • In Production, disable info and debug
  • Global.properties - used to set logging level at directory level or set of components 
  • ATG Developer can use(ATGLogColorizer.exe) tools to color log output   

Log files found in below location:
    /ATGDIR/home/logs
    /JBOSS/server/atg/logs

Inserting Servlets in the DAF Pipeline

Inserting Servlets in the Pipeline
All pipeline servlet classes directly or indirectly implement interface atg.servlet.pipeline.PipelineableServlet.

The PipelineableServlet interface has two sub-interfaces that provide more flexibility for inserting new servlets into the pipeline:

  1. atg.servlet.pipeline.InsertableServlet
  2. atg.servlet.pipeline.DispatcherPipelineableServlet
InsertableServlet
The InsertableServlet interface lets a servlet insert itself into the pipeline when the service starts, without requiring changes to servlets already in the pipeline, through the insertAfterServlet property, which points back to the preceding servlet. The inserted servlet reads the preceding servlet’s nextServlet property and points to it as the next servlet to execute after itself.

Here are the steps to add an InsertableServlet to the servlet pipeline:
1) Write your servlet by extending atg.servlet.pipeline.InsertableServletImpl

package com.foo.endeca.assembler;  
import java.io.IOException;
import javax.servlet.ServletException;
import atg.core.util.StringUtils;
import atg.eai.framework.toolkit.IdLookup;
import atg.servlet.DynamoHttpServletRequest;
import atg.servlet.DynamoHttpServletResponse;
import atg.servlet.pipeline.InsertableServletImpl;     

public class SearchkeywordRedirectPipeline extends InsertableServletImpl {
               public void service(DynamoHttpServletRequest request, DynamoHttpServletResponse response) throws IOException, ServletException {
             String searchTerm = null;
            searchTerm = request.getParameter("Ntt");
            //Business logic goes here
            logDebug("URL for searchTerm : " + searchTerm);
            passRequest(request, response);
       }
      
2) Define the servlet as a globally scoped Nucleus component
      $class=com.foo.endeca.assembler.SearchkeywordRedirectPipeline
      $scope=global
      insertAfterServlet=/atg/dynamo/servlet/dafpipeline/CookieBufferServlet

Set the insertAfterServlet property of your servlet to point to the path of the pipeline servlet you want your servlet to follow. For example, you can insert a servlet after CookieBufferServlet as follows:

insertAfterServlet=/atg/dynamo/servlet/dafpipeline/CookieBufferServlet

When the inserted servlet finishes processing, it calls the method passRequest() (defined in InsertableServletImpl), which automatically passes the request and response objects to the next servlet in the pipeline.

Servlet Pipeline - All pipeline servlets in order of execution


You can use the Dynamo Server Admin Component Browser to view request handling pipeline servlets and their sequence within the pipeline:

Component path: /atg/dynamo/servlet/dafpipeline/DynamoHandler/


/atg/dynamo/servlet/dafpipeline/DynamoHandler
/atg/multisite/SiteContextPipelineServlet
/atg/dynamo/servlet/dafpipeline/SecurityServlet
/atg/dynamo/servlet/dafpipeline/TransactionServlet
/atg/dynamo/servlet/dafpipeline/ThreadUserBinderServlet
/atg/dynamo/servlet/dafpipeline/PathAuthenticationServlet
/atg/dynamo/servlet/dafpipeline/URLArgumentServlet
/atg/dynamo/servlet/dafpipeline/DynamoServlet
/atg/dynamo/servlet/dafpipeline/ProfileRequestServlet
/orion/locale/servlet/UpdateLocaleServlet
/orion/location/servlet/UpdateLocationServlet
/atg/dynamo/servlet/dafpipeline/ProfilePropertyServlet
/atg/dynamo/servlet/dafpipeline/SessionEventTrigger
/atg/dynamo/servlet/dafpipeline/SiteSessionEventTrigger
/atg/search/servlet/pipeline/SearchClickThroughServlet
/atg/dynamo/servlet/dafpipeline/PageViewServletTrigger
/atg/dynamo/servlet/dafpipeline/SessionSaverServlet
/atg/dynamo/servlet/dafpipeline/AccessControlServlet
/atg/dynamo/servlet/dafpipeline/PromotionServlet     
/atg/dynamo/servlet/dafpipeline/CommerceCommandServlet   
/atg/dynamo/servlet/pagecompile/DAFDropletEventServlet
/atg/dynamo/servlet/dafpipeline/MimeTyperServlet
/atg/dynamo/servlet/dafpipeline/ExpiredPasswordServlet
/atg/dynamo/servlet/dafpipeline/CookieBufferServlet
/foo/endeca/assembler/SearchkeywordRedirectPipeline                     - New Servlet
/atg/endeca/assembler/AssemblerPipelineServlet
/atg/dynamo/servlet/dafpipeline/MimeTypeDispatcher
    dynamo-internal/html : /atg/dynamo/servlet/dafpipeline/FileFinderServlet
/atg/dynamo/servlet/dafpipeline/TailPipelineServlet

DAF : Request-Handling Pipeline Servlets

You can use the Dynamo Server Admin Component Browser to view request handling pipeline servlets and their sequence within the pipeline:

Component path: /atg/dynamo/servlet/dafpipeline/DynamoHandler/

By default, PageFilter is mapped to handle JSP requests. When the application server invokes PageFilter, it checks the request and response for a reference to a Dynamo request and response pair. The pair does not exist, so PageFilter starts the DAF servlet pipeline by calling DynamoHandler, the first servlet in the pipeline.

/WEB-INF/web.xml



Servlet Pipeline(v11.1) - All pipeline servlets in order of execution.

           HTTP Request
                    |
                    |
                   V
/atg/dynamo/servlet/dafpipeline/DynamoHandler
/atg/multisite/SiteContextPipelineServlet
/atg/dynamo/servlet/dafpipeline/SecurityServlet
/atg/dynamo/servlet/dafpipeline/TransactionServlet
/atg/dynamo/servlet/dafpipeline/ThreadUserBinderServlet
/atg/dynamo/servlet/dafpipeline/PathAuthenticationServlet
/atg/dynamo/servlet/dafpipeline/URLArgumentServlet
/atg/dynamo/servlet/dafpipeline/DynamoServlet
/atg/dynamo/servlet/dafpipeline/ProfileRequestServlet
/orion/locale/servlet/UpdateLocaleServlet
/orion/location/servlet/UpdateLocationServlet
/atg/dynamo/servlet/dafpipeline/ProfilePropertyServlet
/atg/dynamo/servlet/dafpipeline/SessionEventTrigger
/atg/dynamo/servlet/dafpipeline/SiteSessionEventTrigger
/atg/search/servlet/pipeline/SearchClickThroughServlet
/atg/dynamo/servlet/dafpipeline/PageViewServletTrigger
/atg/dynamo/servlet/dafpipeline/SessionSaverServlet
/atg/dynamo/servlet/dafpipeline/AccessControlServlet
/atg/dynamo/servlet/dafpipeline/PromotionServlet                       — CORE COMMERCE
/atg/dynamo/servlet/dafpipeline/CommerceCommandServlet     — CORE COMMERCE
/atg/dynamo/servlet/pagecompile/DAFDropletEventServlet
/atg/dynamo/servlet/dafpipeline/MimeTyperServlet
/atg/dynamo/servlet/dafpipeline/ExpiredPasswordServlet
/atg/dynamo/servlet/dafpipeline/CookieBufferServlet
/atg/endeca/assembler/AssemblerPipelineServlet
/atg/dynamo/servlet/dafpipeline/MimeTypeDispatcher
    dynamo-internal/html : /atg/dynamo/servlet/dafpipeline/FileFinderServlet
/atg/dynamo/servlet/dafpipeline/TailPipelineServlet

How to load ATG component on Server startup?

When you start up an application, Nucleus reads the configuration path. The out-of-the-box DAS module has (/DAS/config/config.jar/Nucleus.properties) Nucleus.properties component.

Component path: /nucleus/
$class=atg.nucleus.Nucleus
# the default initially resolved service
initialServiceName=/Initial

The initialServiceName property instructs Nucleus to configure and start up its initial service using Initial.properties

Component path: /nucleus/Initial
Configuration: /nucleus/Initial/?propertyName=serviceConfiguration
$class=atg.nucleus.InitialService
initialServices=\
        atg/dynamo/service/PerformanceMonitor,\
/atg/Initial,\
VMSystem,\
/atg/dynamo/StartServers,\
        /atg/dynamo/server/ServerMonitor


In nucleus, to start any custom component at start up(when ATG server starts), Layer /nucleus/Initial.properties as below:

initialServices+=\
                /atg/search/CustomEndecaDimIdCacheService

ATG User Profile Basics

OOTB ATG Manages user profiles with a SQL repository
SQL Repository Component : /atg/userprofiling/ProfileAdapterRepository
Definition File: /atg/userprofiling/userProfile.xml
Current user represented using Profile component (/atg/userprofiling/Profile) and exposes all the properties from the userProfile.xml

There are two types of users:
1) External Users

            Web Site registered users and are stored in ProfileAdapterRepository
2) Internal Users

        Company users who need access to BCC, CSC etc.. and are stored in InternalProfileRepository

Profile Repository definition file layering: (/atg/userprofiling/ProfileAdapterRepository/?propertyName=definitionFiles)

/DPS/config/profile.jar/atg/userprofiling/userProfile.xml
/DSS/config/config.jar/atg/userprofiling/userProfile.xml
/DCS/config/config.jar/atg/userprofiling/userProfile.xml
/APPLICATION_NAME/config/config.jar/atg/userprofiling/userProfile.xml

ProfileFormHanlder:
Component path: /atg/userprofiling/ProfileFormHandler/
This component helps to create, update, login, logout, change password etc…

Various methods available are:
  • handleCreate()
  • handleUpdate()
  • handleCancel()
  • handleDelete()
  • handleLogin()
  • handleLogout()
  • handleChangePassword()
How to create a new user?
Here is a code snippet:

 
 

How to check if user is logged in or Anonymous?
Using /atg/userprofiling/Profile.transient property. It returns false, if the Profile is saved. Otherwise true will be returned.

 

ATG Component layering and how it works?

The config files (.properties) are layered in ATG. If the same .property files is present in modules which are dependent, then it will merge the property values.

Scenario #1:
Module A has X.properties with values name and age and depends on Module B which has X.properties with age and address.


When Module A component is involved it takes the values of age (overridden in A) and name from X.properties of A and address from X.properties of B.

Scenario #2:
Multi value property
#1    X.properties in the config of component contains

              vehicles=car, bike
        X.properties in the localconfig contains
              vehicles=bus
Then when this is used in the jsp then only bus is selected.

#2 To add all items, then, we need to use the below notation in the overridden file:
               vehicles+=bus

#3 If we need car and bus and bike to be removed then, we need to use the below notation in the overridden file:

              vehicles+=bus
              vehicles-=bike

ATG Repository queries using dyn/admin

Product Catalog
Component: /atg/commerce/catalog/ProductCatalog/
 

Profile Adapter Repository
Component: /atg/userprofiling/ProfileAdapterRepository/
 


Order Repository
Component:  /atg/commerce/order/OrderRepository/
 


ATG Component scope

Component Scope:
1) global
2) session
3) request

global can access only global
session can access session and global
request can access request, session and global

Global:

$scope=global
- Default scope 
- Its instance is shared by users across all the sessions that exist for the application (Not similar to application scope of J2EE as global scope components are accessible across application but across ATG server instances)
- Any user which accesses the application can change the values of a global scoped component

Session:
$scope=session
- A separate instance is provided for each session or user
- Session by default valid for 30 mins


How to track and manage user sessions?
Use component:  /atg/dynamo/servlet/sessiontracking


 

Ex: OOTB Session based component /atg/userprofiling/Profile

Request:

$scope=request
 - Each request gets own copy of component
- A new instance will be generated for the component
- Formhandler is always request scoped

SEO Best Practices : How to Block false bots or Hackers IP?

Using IP based filtering will catch out rogue bots masquerading as major bots. Also, you can use reverse DNS lookup and compare the names of bots approaching. 

ATG Commerce has a pipeline servlet that handles the blocking of requests from certain IP addresses.
 
/atg/dynamo/servlet/pipeline/BlockIPServlet 

# set to false to disable
enabled=true
# IP Lists
blockedIPs=152.52.91.12,\
143.13.65.1