ATG Interview Question Part-2

Question: Explain the steps for writing Custom Droplet? 
Answer:
Step 1: Create a java class extending atg.servlet.DynamoServlet and overriding the service (DynamoHttpServletRequest pRequest, DynamoHttpServletResponce pResponse) throw ServletException, IOException method.




Step 2: Create ATG Component for the class, The scope of the component should be global.
$class = com.test.droplet.SayHelloDroplet
$scope=global
$description=print the value under droplet

Step 3: Declare the droplet in the JSP



Input Parameter JSP Side:
- Using value tag
- Using param tag Note: use here page parameter name.
- Using bean tag
Input Paramater Java Side:
- String current=pRequest.getParamater(PARAM_CURRENT_PAGE);

Question: Difference between CartModifierformHandler and shoppingCartfrom handler?
Answer:
CartModifierFromHandler: Used to modify the shopping cart by adding item, deleting items and modifying the item quantities of item in cart and preparing for checkout process. Typically when using this you would have to handle checkout flow yourself by ExpressChecoutFromHandler in case of express checkout and in case of full checkout by using ShippingGroup and PaymentGroup from handlers and finally commitFromHanlder to confirm and commit the order.
ShoppingCartFormHandler - Used for handling cart management (add/remove/adjust item quantity) and checkout process (shipping, billing, committing order). This provides an easier and simpler interface than using CartModifierFormHandler along other form handlers because in ShoppingCartFormHandler various functions for cart management to checkout are exposed via different handleXXX methods each having a preXXX and postXXX to extend the functionality if required. There is one Full ShoppingCartFormHandler also which extends ShoppingCartFormHandler and adds the functionality like handling multiple payment groups, split shipping, express checkout.
To summarize, ShoppingCartFormHandler provides simpler cart management and checkout implementation all in itself. Whereas CartModifierFormHandler doesn't provide you the checkout flow and therefore CartModifierFormHandler based implementation would not be that simple and require other form handlers. But CartModifierFormHandler would provide some benefits like better handling and security for concurrent updates of orders, a more flexible payment/shipping group management for use with multiple shipping or payment groups along with other things.

Question: In ATG Order State?
Answer:
INCOMPLIT_ORDER Order is undefined and has not been checkout by customer yet. 
SUBMIT_ORDER The order has been submitted to the warehouse staff to begin fulfilment.
REMOVE The order has been cancelled. It will not be shipped to the customer.
APPROVED This order has been approved by either an approver of the organization or an agent. 
PENDING_APPROVAL The order requires the approval of an approver of the organization or the agent before it can complete the checkout process.
PRENDING_REMOVE The order is in the process of being cancelled.
INPROCESS When fulfilment server will start it will capture all SUBMIT_ORDER and change the state INPROCESS.
PROCESSED When all the order has shipped, Change the state PROCESSED.

Question; What is MutableRepository?
Answer: 
Some repository services implement MutableRepository, a subclass of Repository. The SQL repository implements this interface. The MutableRepository interface defines functions for four operations: creating, adding, updating, and removing repository items:

1. createItem();
2. addItem();
3. removeItem();
4. updateItem();

Question: Repository API?
Answer: 
- set of interfaces that are used for generic data access.
- use to manipulate repository items within Java code, including retrieving, creating, updating, deleting, and querying for items.
- provides generic data access calls that mask the underlying data store from the developer.(any database can be use as it convert the data in repository objects)

Interface Method
Repository getItem();getView();
RepositoryItem getPropertyvalue( );
RepositoryView executeQuery( );
MutableRepository addItem,CreateItem,getItemForUpdate();updateItem(); removeItem(); 
MutableRepositoryItem setPropertyValue();


  • Repository: Is used to gain access to a given RepositoryItem when the ID is known; is also used to obtain a RepositoryView
  • RepositoryItem: Returns the property values for an individual item from the repository.
  • RepositoryView: Used to execute queries to return an array of RepositoryItem objects
  • MutableRepository: Provides methods used to insert, update, and delete RepositoryItem objects
  • MutableRepositoryItem: Is used to change or set the values of a RepositoryItem

The API provides generic data access calls so that the ATG developer can use the same method calls for LDAP and SQL data stores.
MutableRepository

  • Repository and RepositoryItem provide a read-only view of repository elements.
  • MutableRepository is an extension that enables repository elements to be Created, Updated, Deleted.
  • MutableRepository also provides appropriate cache synchronization.
  • MutableRepository objects are copies of the real objects that can be altered by the application. Because changes are not written back on each change, performance is not affected. On a call to update the repository, a new transaction is started in which its contents are written back to the repository.

Question: Scopes in ATG component?
Answer:
Scope is a nucleus variable. The nucleus properties are processed by $ sign in the configuration files.
Global: If a component has a global scope, its’ instance is shared by users across all the session that exist for the application Any user which accesses the application can change the value of the global scope component. (This means that the state of the component is the same for all users of the application.)
One component copy shares every user.
Example: $class=com.mypackage.Person
                 $scope=global
                  Name=Surya
                  Age=20 
NOTE: If we do not specify $ scope variable, and it is not specifies in any of the upper-layer of the component. Nucleuses consider is scope as “global” by default. 
Session: For a component scoped as session, a separate instance is providing for each session (or user). ATG uses cookies and re-written URL’s to identify requests originating a single browser session. If session is inactive (request are not made) for a specific period time. Session scoped components are remove from that session and any runtime value of these component are last.
One component copy shares only one user.
Example :$class = com.myPackage.Person
                 $scope = session
                 
Request: For each request for component, a new instance will be generated for that component. After the request completes, the instance is lost and all it’s runtime value with it. Even if two requests are generated for a component in same session, nucleus will create two separate instance for the requested component. Request scope components are generally used for from handling. This is because, we don’t want our from to manipulated by multiple request in same session or globally by user across the world. the same session come in at the same time.
One Component copy share for every request.
Window: Share for every browser base.
Note: By Default Droplet has Global Scope and Formhandler has request or session. A very important point which needed to here is that, a component can always refer to component which a scope equal to greater then it’s own scope.
Example: A global scope component CANNOT refer to session or request component.


Question: what are ATG Components follow rules ?
Answer:
  1. You can inject request/session/global scoped component into a request scope component Ex: ProfileFromHandler can have Tools/manager.
  2. You can inject session/global scoped component into a session scope component EX: Session scope Manager should have only session scope component or global scoped Tools/Manager injected in it.
  3. You can inject only global scope component into global scope component Ex: Droplet which is global Scope can only hold other global scoped component injected into it.
  4. Always pass the request or session scope objects to global scope component method instead of resolve component.


Question: How to maintain profile for guest or anonymous user?
Answer: Guest are anonymous users who have not registered have not login.
1. Set  “persistenceAnonymousProfile” property of the  /atg/dynamo/servlet/dafpipeline/ProfileServletRequest to true with new profile will create in database for each anonymous.
2. Set “persistAfterLogout”  property of the /atg/dynamo/servlet/dafpipeline/ProfileServletRequest to true
3. Set the “profileRequestTools “property of the /atg/dynamo/servlet/dafpipeline/ProfileRequestServlet component to /atg/userprofiling/ProfileRequestTools.
4. Enable auto-login by setting the “autoLogin” property to true in the userprofile.xml file.
Example: Store anonymous users:
 # /atg/dynamo/servlet/dafpipeline/ProfileServletRequest
persistAfterLogout=true
persisteAnonymousProfiles=true
Note: If you set up the auto-login
#CookiesManage
sendProfileCookies=true
#ProfileRequestServlet
varifyBasicAuthantication=false  (check password verification,Password are store in (SHA-256) rehashes)

Question: What is the layering in ATG?
Answer: This is one of the most important topics without which customization in ATG is simply not possible.
Layering in ATG refers to overriding component property not component when we place the component at the same config path.
The property in the component picked up at the last in configure path, overrides the properties define in the previous property file.
ATG Support left to write relationship for this:  
Like As DAS DAF DPS DSS DCS 
- set CLASSPATH=”c:\test ; c:\testInfo” 
A c:\music\artists\d\SunShine.properties file containing
$class= atg.music.Artist
$scope=global
name=Sun Shine
genre=folk/pop
We have defined a single global nucleus component of class atg.music.Artist which can be referenced by the name /artists/d/Sun Shine from within Dynamo. Then name property of the instance will be set to Sun Shine and the genre property will be set to folk/pop. In this case even though our Artist bean has website and email properties we have not set these properties so they remain uninitialized.
Nucleus nameScopeJava instance (the bean)/artists/d/SunShine global
atg.music.Artist
name
Sun Shine
genre
rock
website

email



Multiple CONFIGPATH directories.
set CONFIGPATH="c:\music;c:\moreinfo"
A c:\music\artists\d\SunShine.properties file containing
$class= atg.music.Artist
$scope=global
name=Sun Shine
genre=folk/pop

A second c:\moreinfo\artists\d\SunShine.properties file containing
website=http://www.dmb.com
email=dave@dmb.com
genre=rock
Nucleus nameScopeJava instance (the bean)/artists/d/SunShine global
atg.music.Artist
name
Sun Shine
genre
rock
website
http://www.dmb.com
email
dave@dmb.com
Configuration Layering for Arrays, Given the following
set CONFIGPATH="c:\music;c:\moreinfo"
A c:\music\albums\c\Crash.properties file containing
$class= atg.music.Album
$scope=global
title=Crash
tracks=#34, Lay Down Lover
sessionPlayers= Raj kumar, Suraj Kumar

A second c:\moreinfo\albums\c\Crash.properties file containing
tracks=Two Step, Crash
sessionPlayers+=krishna,Jon kupper
Nucleus name
Scope
Java instance (the bean)
/albums/c/Crash
global
atg.music.Album
title
Crash
tracks
Two Step
Crash
sessionPlayers
Raj kumar
Suraj Kumar
Krishna 
Jon kupper




No comments: