Friday, June 13, 2014

Life cycle phases of JSP

JSP is a servlet written in HTML format. Basically JSP can have java code in HTML and servlet can have HTML code in Java. The JSP engine does under go through different phases before disposing it. There are essentially 7 phases.
  • Page translation : Page is parsed, and a java file which is a servlet is created.
  • Page compilation : Page is compiled into a class file
  • Page loading : This class file is loaded.
  • Create an instance : Instance of servlet is created
  • Initialization : jspInit() method is called
  • Servicing : _jspService is called to handle service calls
  • Destroy : _jspDestroy is called to destroy it when the servlet is not required.

ATG CSC | Customize and configure return shipping address page

Following are the steps to configure the shipping address for returns,
  • Create a new jsp file that contains your return shipping address
Ship return items to:
My Company
Attn:Returns
100 Main Street
My City, My State
My Zip
  • Open ReturnShippingAddressRenderer.properties file from the location atg/commerce/custsvc/ui/renderers/ and provide the location of the new JSP file and the contextRoot variable.

  • Save ReturnShippingAddressRenderer.properties

Method types in Java

  • Re-entrant : A Java method in stack is re-entrant means that is allowing multiple concurrent invocations that do not interfere with each other. 
  • Recursive : A function is recursive if it calls itself. Given enough stack space, recursive method calls are perfectly valid in Java though it is tough to debug. Recursive functions are useful in removing iterations from many sorts of algorithms. All recursive functions are re-entrant but not all re-entrant functions are recursive. 
  • Idempotent : Idempotent methods are methods, which are written in such a way that repeated calls to the same method with the same arguments yield same results. For example clustered EJBs, which are written with idempotent methods, can automatically recover from a server failure as long as it can reach another server.

JSP or Servlet pages cached by browser

In order to prevent the dynamic content output by JSP page from being cached by browser, we need to set few HTTP header attributes.Just execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached at the browser. You need both the statements to take care of some of the older browser versions.

<% 
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma\","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>

Java References | Garbage Collection

Java allows a special behavior for garbage collection, unlike most of the other garbage-collected programming languages. A normal reference in Java is known as strong reference. Other than that Java supports three more references.
  • Soft reference mainly used to implement cache. An object that is not reachable by a strong reference (that is, not strongly reachable), but is referenced by a soft reference is called softly reachable. A softly reachable object may be garbage collected at the discretion of the garbage collector. This generally means that softly reachable objects will only be garbage collected when free memory is low, but again, it is at the discretion of the garbage collector. Semantically, a soft reference means "keep this object unless the memory is needed."
  • Weak reference is mainly used to implement weak maps. An object that is not strongly or softly reachable, but is referenced by a weak reference is called weakly reachable. A weakly reachable object will be garbage collected during the next collection cycle. This behavior is used in the class java.util.WeakHashMap. A weak map allows the programmer to put key/value pairs in the map and not worry about the objects taking up memory when the key is no longer reachable anywhere else. Another possible application of weak references is the string intern pool. Semantically, a weak reference means "get rid of this object when nothing else references it."
  • Phantom reference is mainly used to reference objects that have been marked for garbage collection and have been marked finalized, however not been reclaimed. An object that is not strongly, softly or weakly reachable, but is referenced by a phantom reference is called phantom reachable. This allows for more flexible cleanup than is possible with the finalization mechanism alone. Semantically, a phantom reference means "this object is no longer needed and has been finalized in preparation for being collected."

Thursday, June 12, 2014

New ATG 11

New version of ATG 11.0 (Oracle Commerce 11) has lot of changes. Out of which these are the main areas that I found interesting.
  1. Oracle Commerce Naming
  2. Oracle Commerce Platform
  3. Oracle Commerce Business Control Center
  4. Oracle Commerce Workbench
  5. Oracle Commerce Service Center (CSC)
  6. Oracle Commerce Reference Store (CRS)
Oracle Commerce Naming : Oracle has changed the ATG product names and completely removed the ATG brand from the product.

Previous Name
New Name
Oracle ATG Web Commerce
Oracle Commerce Platform
Oracle ATG Web Commerce Merchandising
Oracle Commerce Merchandising
Oracle ATG Web Commerce Service Center
Oracle Commerce Service Center
Oracle Endeca Guided Search
Oracle Commerce Guided Search
Oracle Endeca Experience Manager
Oracle Commerce Experience Manager
Oracle Endeca Relationship Discovery
Oracle Commerce Relationship Discovery
Oracle ATG Web Commerce Developer and
Administrator
Oracle Commerce Developer and Administrator
Oracle Endeca Developer
Oracle Commerce Guided Search and Experience Manager Developer
Oracle Commerce Platform
  • Single Sign On with Oracle Access Manager Integration-The Oracle Commerce Business tools (BCC and Workbench) have been integrated with Oracle Access Manager (OAM). The BCC and Workbench can work with OAM to utilize OAM as the point of authentication for access to the tools. This allows a user to access both tools using the same credentials. Once authenticated in one tool, links are provided for the user to jump directly to the other tool without re-authentication. Likewise, logging out of one tool ends the session for both tools.
  • CA Data Import Performance Improvements - The content administration data import API’s and scripts to import data in CA project have been updated to improve performance. And performance of New API is 10 times faster compared to previous release. The new scripts use APIs that bypass the repository layer and issue SQL directly to the underlying database.
  • CIM Internationalization (command line tool) - With Commerce 11, CIM’s prompts and menus have been translated into 22 languages.
  • Environment Promotion Improvements- Oracle Commerce Guided Search and Experience Manager applications go through a life cycle of authoring, previewing, and live modes. Authoring and previewing typically occur in a staging environment, while live mode serves as the production environment supporting customer traffic
Oracle Commerce Business Control Center
  • Product Content Management (PCM)
    • Image Thumbnails in the Merchandising UI
    • Site Context in Browse Mode
    • Export Prices (This feature enables users to export prices from within the Merchandising Flex UI into an Excel or CSV file. The set of exportable properties for the assets are fixed and cannot be edited in the UI)
  • Promotions Management
    • Get Group Discount (group discount is new template which lets to discount to group of items (SKUs, products, Categories))
    • Maximum Discounts Per Order
    • Maximum Coupons Per Order- Site level
Oracle Commerce Workbench
  • Localization - Workbench can be operated in 22 languages listed below. Experience Manager cartridges that come out of the box are localized in the same languages as the rest of the workbench. Custom built cartridges may also be localized.
  • Automatic Phrasing - Business users can manage multi-word search terms that will then be treated as a phrase in search queries
  • Relevance Ranking Evaluator - Business users can run multiple searches simultaneously, using different relevance ranking modules and other search parameters to compare the order and quality of results returned. Users can test one or more of the sixteen different relevance ranking modules to influence search
  • User Segments - Experience Manager can now refer to user segments created in the BCC
  • Experience Manager Preview - Experience Manager now allows business users to make edits and preview these changes without needing to mark their changes as live for production. Business users can preview changes made by one or more users at any point in time.
Oracle Commerce Service Center
  • Service Enablement (Phase two services) - Added the following services
    • Initiating a return or an exchange
    • Displaying refund amounts
    • Displaying refund confirmation
    • Receiving a return
    • Cancelling a return or an exchange
    • Granting, overriding, and removing promotions
    • Searching for promotions and identifying lost or changed promotions
    • Adding store credit
    • Getting closeness qualifiers messaging
    • Reviewing, modifying, and approving an order
    • Creating, submitting, activating, deactivating, and confirming a scheduled order
    • Working with scheduled order templates
    • Changing price lists and catalogs
    • Searching for catalogs
    • Searching, browsing, creating, deferring, reassigning, printing, editing a ticket
    • Changing other agent preferences such as password updates and logout
    • Composing, uploading attachments, and sending emails
  • ATG search replaced with database - Optimized search for orders and profiles, compatible with below mentioned databases
    • Oracle
    • MySQL
    • SQL Server
    • DB2
  • CSC support for the new retail specific promotions
    • Get Group Discount
    • Maximum discounts per order
    • Maximum coupons per order
Oracle Commerce Reference Store
  • Oracle Commerce provides starter CRS applications for the following three channels:
    • Web
    • Mobile Web
    • iOS Universal (iPhone and iPad)
  • Features are added to all three channels
    • Home Page Driven by Experience Manager
    • New Storefront Branding- The ATG Store has been rebranded as CRS Store and the ATG Home store has been rebranded as the CRS Home store
  • CRS Web additional features are
    • Store Locator Pages
    • SEO Best Practices
    • Brand Landing Page
    • Auto-Suggest: The CRS Web application now demonstrates the use of the Guided Search Auto-Suggest capabilities
  • CRS Mobile Apps features are
    • Product Returns- The CRS product returns feature builds on the core Commerce returns functionality to enable a shopper to easily initiate a return on orders (both as a whole order, or as individual returnable items contained within the order) within the account management area
22 Languages supported in CIM and workbench are,
    • Chinese (Simplified)
    • Finnish
    • Hungarian
    • Russian
    • Chinese (Traditional)
    • French (France)
    • Italian (Italy)
    • Spanish (Intl Sort)
    • Czech
    • German (Germany)
    • Polish
    • Swedish
    • Danish
    • Greek
    • Portuguese (Brazil)
    • Thai
    • Dutch (Netherlands)
    • Japanese
    • Portuguese (Portugal)
    • Turkish
    • English, US
    • Korean
Additional locales for date and time formats
    • English (US)
    • English (UK)
    • English (Australia)
    • English (Canada)

Wednesday, June 11, 2014

ATG - Shipping address to the order or shipping group

How do you set the shipping address to the order or shipping group?

We use the ShippingGroup droplet to display all the available shipping addresses. The ShippingGroupDroplet will get the available addresses from the Profile's shipingAddress and secondaryAddresses properties.Then the user will select the shippingAddress from the list. Then the selected address will be set the current shipping group by calling the handleApplyShippingGroups method of ShippingGroupFormHandler.

We can create a shipping group manually by using the ShippingGroupManager.createShippingGroup by passing the address. After that we call ShippingGroupManager.addShippingGroupToOrder method.The user will also select the shipping method and set to the shipping group such as Next Day , Two Day or Ground. We will use AvailableShippingMethods droplet which fetches all the shipping method names from the Shipping calculators. Each Shipping Calculator has a property called shippingMethod.

ATG - New commerce item type

How to create new commerce item type?

In the orderReposiry.xml, create an item descriptor by extending the default commerce item using inheritance concept (specifying super-type and sub-type) and adding the new properties with new table under this item descriptor. Then we will create a new java bean by extending the CommerceItemImpl and adding setters and getters for the properties created in the new commerce item item descriptor. After that we will specify the new commerce item details in the OrderTools.properties and specify commerceItemTypeClassMap and beanNameToItemDescriptorMap.

How to add newly created commerce item type to the order?

We will set up a map of sku item types to the commerce item types in the CommerceItemManager.properties. Then we will override the CommerceItemManager's createCommerceItem method. We will take the skuId (catalogRefId) and find its SKU item type and then from this name we will look up the map values in the CommerceItemManager.properties to search for its related commerceItem type to create.


ATG - Standard catalog and Custom catalog

Basic difference

The standard catalog is the single catalog shown to all users. Each user sees the same set of categories and products (There is no item descriptor called 'catalog'). The custom catalog allows us to create multiple catalogs which are intended to show differently to different users. We can target a catalog to a specific user or an organization depending upon the business rules. For example, we can create a separate catalog for each country based on locale. Each locale will be having a separate catalog.

Showing the departmental menu

In standard catalog few categories can be marked with isRoot flag true which make them root categories. For showing up the menu we can use OOTB RootCategories targeter using TargetingForEach droplet that will get all the categories of the catalog whose root property is set to true.In custom catalog the profile will have a default catalog set and Profile.catalog.allRootCategories property will give all the root categories of the catalog

Module difference

Standard catalog is part of the DCS module, whereas custom catalog properties are from DCS.CustomCatalog module.

Profile difference

In custom catalog a new property has been added to the profile named 'catalog' which would store the default catalog of the profile. This property is set either through scenario (when the user logs in) or through request pipeline.