Sunday 13 December 2015

Use xslt to Index xml File into Endeca

Here is the small example with steps to use xslt while indexing xml file into Endeca. 

1. First of all configure xml file in Record Adapter of pipeline. 

 

2. Then click on Transformer tab.


Here configure below two fields.

a. Type : The file format of the transformation style sheet.The only valid value is XSLT.
b. URL :  Specifies the location of the .xsl file. The path is either an absolute path or a path relative to the location of the Pipeline.epx file. In this example transform.xsl file is located at the location of the pipeline.epx file.

In this example xslt is used to convert name to uppercase.
------------------------------------------------------------------------------------------------------------------------
 transform.xsl
------------------------------------------------------------------------------------------------------------------------
 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:template match="/">
<RECORDS>
<xsl:for-each select="employees/employee">
    <RECORD>
         <PROP NAME="P_Age">
             <PVAL><xsl:value-of select="age"/></PVAL>
          </PROP>
          <PROP NAME="P_Name">
             <PVAL><xsl:value-of select="translate(name, $smallcase, $uppercase)"/></PVAL>
          </PROP>
          <PROP NAME="Dep_ID">
             <PVAL><xsl:value-of select="depid"/></PVAL>
          </PROP>
    </RECORD>
</xsl:for-each>
</RECORDS>
</xsl:template>
</xsl:stylesheet>
 ------------------------------------------------------------------------------------------------------------------------

 ------------------------------------------------------------------------------------------------------------------------
Sample input xml file (data.xml)
 ------------------------------------------------------------------------------------------------------------------------
 <?xml version="1.0" encoding="UTF-8"?>
<employees>
   <employee>
      <name>Jon</name>
      <age>20</age>
      <depid>123</depid>
   </employee>
   <employee>
      <name>Ban</name>
      <age>30</age>
      <depid>456</depid>
   </employee>
   <employee>
      <name>Kim</name>
      <age>40</age>
      <depid>789</depid>
   </employee>
</employees>
 ------------------------------------------------------------------------------------------------------------------------
3. Run baseline indexing and see the resutls in jspref.



Tuesday 1 December 2015

Resolved | Missing Discover application folders in Tools And Frameworks

After installing Endeca related softwares I tried to provision the Discover reference application. Then realized that discover application related folders are missing from installation.

Root Cause : ToolsAndFrameworks was installed with installation type Minimal option. This option does not includes the reference application.

Solution : Install ToolsAndFrameworks with installation type Complete option.

Saturday 28 November 2015

Interesting ATG Findclass Utility

While going through ATG documentation found one interesting utility. This is Findclass Utility. This will find the .class or JAR file from which a Java class has been loaded. It will also print the CLASS_VERSION information if found.

This utility can be accessed using below URL on your Oracle ATG Web Commerce server.

http://server:port/dyn/dyn/findclass.jhtml

Enter the name of the class in the Class Name field and click Find Class button.

For example ,here I have searched for atg.commerce.order.OrderImpl class
.

Find Class


To print debug information append &debug=true to URL. Below is screen capture for OrderImpl with debug information.


Find Class with Debug Information


Class name field accepts class name in below formats.
  • atg.commerce.order.OrderImpl
  • atg.commerce.order.OrderImpl.class
  • atg/commerce/order/OrderImpl.class
  • /atg/commerce/order/OrderImpl.java

Friday 23 October 2015

Resolved | atg.repository.RepositoryException: createItem() was called with an existing ID : 'Prod200013' for type 'product'. Use getItemForUpdate() instead

While importing product data sheet into BCC got RepositoryException.Below is the stack trace of error.

---    atg.repository.RepositoryException: createItem() was called with an existing ID : 'Prod200013' for type 'product'. Use getItemForUpdate() instead.
at atg.adapter.version.VersionRepository.createItem(VersionRepository.java:1907)
at atg.adapter.version.VersionRepository.createItem(VersionRepository.java:1152)
at atg.remote.assetmanager.editor.service.RepositoryAssetServiceImpl.copyItemWithNewId(RepositoryAssetServiceImpl.java:754)
at atg.remote.assetmanager.editor.service.RepositoryAssetServiceImpl.doAddAsset(RepositoryAssetServiceImpl.java:517)
at atg.remote.assetmanager.editor.service.AssetServiceImpl.addAsset(AssetServiceImpl.java:379)
at atg.remote.assetmanager.transfer.service.ImportEngine.importSingleAsset(ImportEngine.java:421)
at atg.remote.assetmanager.transfer.service.ImportEngine.importAssets(ImportEngine.java:247)
at atg.remote.assetmanager.transfer.service.TransferService.performImport(TransferService.java:270)
at sun.reflect.GeneratedMethodAccessor647.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:421)
at atg.flex.messaging.services.TransactionalJavaAdapter.invoke(TransactionalJavaAdapter.java:127)
at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1503)
at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:884)
at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121)
at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146)
at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:278)
at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:322)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at atg.servlet.pipeline.TailPipelineServlet.service(TailPipelineServlet.java:161)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.DispatcherPipelineServletImpl.service(DispatcherPipelineServletImpl.java:253)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.http.CookieBufferServlet.service(CookieBufferServlet.java:97)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.userprofiling.ExpiredPasswordServlet.service(ExpiredPasswordServlet.java:356)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.MimeTyperPipelineServlet.service(MimeTyperPipelineServlet.java:206)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.droplet.DropletEventServlet.service(DropletEventServlet.java:609)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.epub.servlet.LocaleServlet.service(LocaleServlet.java:63)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.epub.servlet.ProjectServlet.service(ProjectServlet.java:87)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.epub.servlet.PublishingSecurityServlet.service(PublishingSecurityServlet.java:58)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.commerce.order.CommerceCommandServlet.service(CommerceCommandServlet.java:128)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.commerce.promotion.PromotionServlet.service(PromotionServlet.java:191)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.userprofiling.AccessControlServlet.service(AccessControlServlet.java:655)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.sessionsaver.SessionSaverServlet.service(SessionSaverServlet.java:2425)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.userprofiling.PageEventTriggerPipelineServlet.service(PageEventTriggerPipelineServlet.java:169)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.multisite.SiteSessionEventTriggerPipelineServlet.service(SiteSessionEventTriggerPipelineServlet.java:139)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.userprofiling.SessionEventTrigger.service(SessionEventTrigger.java:490)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.userprofiling.ProfilePropertyServlet.service(ProfilePropertyServlet.java:208)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.userprofiling.ProfileRequestServlet.service(ProfileRequestServlet.java:437)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.CachePreventionServlet.service(CachePreventionServlet.java:119)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.DynamoPipelineServlet.service(DynamoPipelineServlet.java:469)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.URLArgumentPipelineServlet.service(URLArgumentPipelineServlet.java:280)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.PathAuthenticationPipelineServlet.service(PathAuthenticationPipelineServlet.java:370)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.userprofiling.sso.PassportServlet.service(PassportServlet.java:554)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.security.ThreadUserBinderServlet.service(ThreadUserBinderServlet.java:91)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.dtm.TransactionPipelineServlet.service(TransactionPipelineServlet.java:212)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.SecurityServlet.service(SecurityServlet.java:191)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.multisite.SiteContextPipelineServlet.service(SiteContextPipelineServlet.java:303)
at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:135)
at atg.servlet.pipeline.HeadPipelineServlet.passRequest(HeadPipelineServlet.java:1169)
at atg.servlet.pipeline.HeadPipelineServlet.service(HeadPipelineServlet.java:855)
at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:250)
at atg.filter.dspjsp.PageFilter.innerDoFilter(PageFilter.java:287)
at atg.filter.dspjsp.PageFilter.doFilter(PageFilter.java:150)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
 

Root Cause : There were two products in the import data file with same id.

Solution : Remove duplicate ids from import file. Correct your data.

Saturday 15 August 2015

BCC | Revert Asset to previous version (one of the older version from history)

As we know that BCC maintains the assets version. For newly created assets it assigns the version 1. Each time you modify the assets. It increments version by 1. The highest version number of that assets is the one which is deployed on production server. Sometime we need to revert assets to older version. In the other words we need to deploy some particular version of the asset from asset history. This is one of the benefits of assets versioning.

Here are the steps to deploy assets from history

Create content administration project in BCC.




Add asset to the project.



Click on  asset.
On Asset page click on History Tab.
On history tab click on the version you want to revert.




Scroll down on this page then click on revert asset to this version button.



Then deploy the project.
 

Saturday 25 July 2015

ATG-Endeca Integration | Property 'contentItem' not found on type atg.servlet.DynamoHttpServletRequest

While trying to access contentItem returned by InvokeAssembler. Got below exception trace on server console.
========================================================================
javax.el.PropertyNotFoundException: Property 'contentItem' not found on type atg.servlet.DynamoHttpServletRequest
        at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
        at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:170)
        at javax.el.BeanELResolver.property(BeanELResolver.java:279)
        at javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
        at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
        at org.apache.el.parser.AstValue.getValue(AstValue.java:118)
        at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
        at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:925)
        at org.apache.jsp.cartridges.ContentSlot.ContentSlot_jsp._jspx_meth_dsp_005fgetvalueof_005f0(ContentSlot_jsp.java:255)
        at org.apache.jsp.cartridges.ContentSlot.ContentSlot_jsp._jspx_meth_dsp_005fpage_005f1(ContentSlot_jsp.java:197)
        at org.apache.jsp.cartridges.ContentSlot.ContentSlot_jsp._jspService(ContentSlot_jsp.java:107)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)
        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)
        at atg.servlet.WrappingRequestDispatcher.include(WrappingRequestDispatcher.java:123)
        at atg.taglib.dspjsp.IncludeTag.doEndTag(IncludeTag.java:883)
        at atg.taglib.dspjsp.DelegatingTag.doEndTag(DelegatingTag.java:147)
        at atg.taglib.dspjsp.AbstractRenderContentItem.doEndTag(AbstractRenderContentItem.java:234)
        at atg.taglib.dspjsp.DelegatingTag.doEndTag(DelegatingTag.java:147)
        at org.apache.jsp.index_jsp._jspx_meth_dsp_005frenderContentItem_005f0(index_jsp.java:410)
        at org.apache.jsp.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:381)
        at org.apache.jsp.index_jsp._jspx_meth_dsp_005fpage_005f1(index_jsp.java:203)
        at org.apache.jsp.index_jsp._jspService(index_jsp.java:112)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at atg.service.configuration.ResponseWrappingConfiguration.invokeFilterChainWithPossibleWrapping(ResponseWrappingConfiguration.java:458)
        at atg.servlet.pipeline.TailPipelineServlet.service(TailPipelineServlet.java:174)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.pipeline.DispatcherPipelineServletImpl.service(DispatcherPipelineServletImpl.java:275)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.endeca.assembler.AssemblerPipelineServlet.service(AssemblerPipelineServlet.java:458)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.http.CookieBufferServlet.service(CookieBufferServlet.java:119)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.userprofiling.ExpiredPasswordServlet.service(ExpiredPasswordServlet.java:383)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.pipeline.MimeTyperPipelineServlet.service(MimeTyperPipelineServlet.java:228)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.droplet.DropletEventServlet.service(DropletEventServlet.java:696)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.commerce.order.CommerceCommandServlet.service(CommerceCommandServlet.java:150)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.commerce.promotion.PromotionServlet.service(PromotionServlet.java:213)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.userprofiling.AccessControlServlet.service(AccessControlServlet.java:696)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.sessionsaver.SessionSaverServlet.service(SessionSaverServlet.java:2452)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.userprofiling.PageEventTriggerPipelineServlet.service(PageEventTriggerPipelineServlet.java:191)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.search.servlet.SearchClickThroughServlet.service(SearchClickThroughServlet.java:418)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.multisite.SiteSessionEventTriggerPipelineServlet.service(SiteSessionEventTriggerPipelineServlet.java:161)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.userprofiling.SessionEventTrigger.service(SessionEventTrigger.java:512)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.userprofiling.ProfilePropertyServlet.service(ProfilePropertyServlet.java:230)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.userprofiling.ProfileRequestServlet.service(ProfileRequestServlet.java:461)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.pipeline.DynamoPipelineServlet.service(DynamoPipelineServlet.java:491)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.pipeline.URLArgumentPipelineServlet.service(URLArgumentPipelineServlet.java:298)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.pipeline.PathAuthenticationPipelineServlet.service(PathAuthenticationPipelineServlet.java:392)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.security.ThreadUserBinderServlet.service(ThreadUserBinderServlet.java:113)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.dtm.TransactionPipelineServlet.service(TransactionPipelineServlet.java:234)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.pipeline.SecurityServlet.service(SecurityServlet.java:196)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.multisite.SiteContextPipelineServlet.service(SiteContextPipelineServlet.java:441)
        at atg.servlet.pipeline.PipelineableServletImpl.passRequest(PipelineableServletImpl.java:157)
        at atg.servlet.pipeline.HeadPipelineServlet.passRequest(HeadPipelineServlet.java:1252)
        at atg.servlet.pipeline.HeadPipelineServlet.service(HeadPipelineServlet.java:930)
        at atg.servlet.pipeline.PipelineableServletImpl.service(PipelineableServletImpl.java:272)
        at atg.filter.dspjsp.PageFilter.innerDoFilter(PageFilter.java:348)
        at atg.filter.dspjsp.PageFilter.doFilter(PageFilter.java:206)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:662)


========================================================================

Here is the solution to this issue.


Configure below listener in the web.xml of your web application.

========================================================================
  <listener>
          <listener-class>atg.taglib.dspjsp.RegisterELResolverServletContextListener</listener-class>
    </listener>

========================================================================

To use this listener your web application must use the servlet 2.5 schema or greater.
 

Saturday 11 July 2015

ATG REST MVC Overview

Nowadays it is very common for enterprise applications to share data and business logic with other applications. This can be easily achieved using web services. This becomes very tricky when providing omni channel support in E-commerce (accessing site using android or any other native application).

ATG allows developers to create their own webservices along with pre-packages services.

These pre-packages services are available in below modules.
  1. DAS.WebServices
  2. DPS.WebServices
  3. DCS.WebServices 
ATG supports two types of REST webservices (webservices APIs).
  1. Legacy REST API
  2. REST MVC API
 

Here I am going to explain REST MVC.

Steps to create New REST MVC Call
  • Create Actor.
  • Define Actor chain(s) for that actor.
  • Register Actor with ActorChainRestRegistry.
  • Create Bean filter (optional).
Steps to create REST Actor
  1. Create Component of atg.service.actor.ActorChainService class.
  2. Define actor chains for this component (xml configuration).
  3. Point definitionFile property of the component to xml file created in step 2.
Below is the example of Hello World Actor

=======================================================================
#/com/test/web/actor/HelloWorldActor.properties
$class=atg.service.actor.ActorChainService
definitionFile=/com/test/web/actor/helloWorldActor.xml
=======================================================================

Actor Chain definition file (helloWorldActor.xml)
 
=======================================================================
<?xml version="1.0" encoding="UTF-8"?>
<actor-template default-chain-id="sayHello" xsi:noNamespaceSchemaLocation="http://www.atg.com/xsds/actorChain_1.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<actor-chain id="sayHello" transaction="TX_SUPPORTS">
       <component id="sayHello" name="/com/test/web/HelloWorld"
           method="sayHello">
      </component>
 </actor-chain>
</actor-template>
=======================================================================

Registering this actor with ActorChainRestRegistry

To register this actor you need to add the actor path with chain id to registeredUrls property of /atg/rest/registry/ActorChainRestRegistry component.

One important thing to remember here is ,that you are registering actor chain not actor. In the case there are more then one chains defined for that actor you need to register each one here. In  other words you can say each chain ID should be registered separately.

By default, no actors are registered.

In below code snippet we are registering sayHello chain. 
=======================================================================
#/atg/rest/registry/ActorChainRestRegistry.properties
registeredUrls=\
         /com/test/web/actor/HelloWorldActor/sayHello

=======================================================================

 ATG REST MVC Supports below Actor Types.
  • Component Actor 
  • Droplet Actor
  • Form Actor
  • JSP Actor
  • Nested Actor
  • Variable Actor 

Filtering in MVC REST

Filtering is used in REST MVC to control the property in the response object. In other words filter is way to configure which properties will be available in the response object. This is to avoid unnecessary data in the response.
 
REST MVC support two types of filters.
  1. Java bean filtering.
  2. Repository item filtering.
Steps to configure filter
  • Layer /atg/dynamo/service/filter/bean/beanFilteringConfiguration.xml 
  • Configure filter in this file
  • Refer this filter in actor chain
  • ATG recommends 3 types of filters
                   Short
                   Summary
                   Detailed


Once filter is defined you can use filter in actor chain using filter-id attribute.

Filter definition example.

======================================================================= 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bean-filtering SYSTEM "dynamosystemresource:/atg/dtds/beanfilter/beanFiltering_1.0.dtd">
<bean-filtering>
<repository name="/atg/userprofiling/ProfileAdapterRepository">
   <item-descriptor name="user">
      <filter id="customDetail" default-include="false">
        <property hidden="false" name="firstName"/>     
        <property hidden="false" name="lastName"/>
      </filter>
   </item-descriptor>
</repository>

</bean-filtering>
======================================================================= 

Using filter in actor chain.  

=======================================================================
 <?xml version="1.0" encoding="UTF-8"?>
<actor-template default-chain-id="summary" xsi:noNamespaceSchemaLocation="http://www.atg.com/xsds/actorChain_1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <actor-chain id="customDetail" transaction="TX_SUPPORTS">
    <component id="profile" name="/atg/userprofiling/Profile" invoke-method-requires-session-confirmation="true" component-var="profile" set-property-requires-session-confirmation="true">
      <output id="profile" filter-id="customDetail" name="profile" value="${profile.dataSource}"/>
    </component>
  </actor-chain>
</actor-template>

=======================================================================  
Note : It is best to define a filter for every object, so that you can control its output. Note that if an object has no filters defined, it will output all properties.

Configure Security in REST MVC 

Once REST call is implemented then It is time to secure it. Security is crucial to avoid unauthorized access. 

Follow below steps to secure rest webservice
  • Create the RuleSetService.
  • Create Access Controller.
  • Add mapping from actor chain to Access Controller in /atg/dynamo/servlet/dafpipeline/AccessControlServlet. 
 
CustomRuleService (Only logged in user can access).

======================================================================= 
#/atg/rest/CustomRuleSetService.properties
$class=atg.targeting.RuleSetService
updatesEnabled=true
rulesFileCheckSeconds=0

# Use must have securityStatus 4 or higher (EXPLICIT-SIGNIN, SECURE-SIGNIN, CERTIFICATE)
ruleSet=<ruleset>\n  <accepts>\n    <rule op\=and tag\="Show">\n      <rule op\=and tag\="Content">\n      </rule>\n      <rule op\=and tag\="Environment">\n        <rule op\=gt>\n          <valueof target\="securityStatus">\n          <valueof constant\="3">\n        </rule>\n      </rule>\n    </rule>\n  </accepts>\n</ruleset>
======================================================================= 

CustomAccessController
 
=======================================================================
#/atg/userprofiling/CustomAccessController.properties
$class=atg.userprofiling.RuleAccessController
enabled=true
# Rules used to determine whether access should be allowed
ruleSetService=/atg/rest/CustomRuleSetService
# URL to redirect to if access is denied
deniedAccessURL=/rest/model/atg/userprofiling/SecurityStatusActor/authenticationRequired
======================================================================= 
 
 AccessControlServlet
 
======================================================================= 
#/atg/dynamo/servlet/dafpipeline/AccessControlServlet.properties
accessControllers=\
   
/com/test/web/actor/HelloWorldActor/sayHello=\
         /atg/userprofiling/CustomAccessController
======================================================================= 
      
ATG REST MVC Key Points
  • Get and Post are supported.
  • Access restriction  by AccessControllerService.
  • Also support implicit objects (session, request).
  • URL syntax http://host:port/rest/model/actor_component/tail.

ATG REST MVC Key Components
  • /atg/rest/Configuration/ 
  • /atg/rest/registry/ActorChainRestRegistry/
  • /atg/dynamo/service/filter/bean/XmlFilterService
  • /atg/dynamo/service/actor/ActorChainValidationService