Monday, July 2, 2018

Docker error WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz: DNS lookup error

While installing docker file, we get DNS lookup error for WARNING: Ignoring http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz: DNS lookup error

To fix, add the below dns configuration in/etc/docker/daemon.json
{
    "dns": ["8.8.8.8"]
}

Sometimes the issue also could with your proxy settings, so either add or remove any http_proxy.

Monday, May 7, 2018

Java Thread Dump in Windows machine

To get the thread dumps on windows machine, get the PID from Windows Task Manager then execute the below command from command prompt.

jstack.exe -l 16256 >>dumps.log

Thursday, May 3, 2018

Enable PriceList View in BCC Merchandising

PriceLists can be managed in BCC as two places.

1. Dropdown in Commerce Assets View



 2. Price List tab when viewing a sku












By default BCC doesn't show both PriceList views.
To enable the dropdown above add below property
#/atg/commerce/pricing/PricingTools.properties
usingPriceLists=true

To enable PriceLists tab on the Sku View add below properties
#/atg/remote/content/assetmanager/ContentConfiguration.properties
showSKUPriceLists=true

There are other properties in this component to control the Pricing tabs.

showProductOrSkuPriceListPricing
showProductPriceLists
showProductsSubSKUsPriceLists
showSKUPriceLists
showSKUPricing

More details on this can be found here https://docs.oracle.com/cd/E41069_01/Platform.11-0/ATGMerchandisingAdminGuide/html/s0504configuringpricingdisplayinmerch01.html


Wednesday, May 2, 2018

ATG JAX-RS Creating End Point

The complete code can be found here:
https://github.com/theshaik/ATGJAXRSServices


Follow below steps to create new JAX-RS rest end point.


1. Create a Java class UserRestResource.jave

package com.demo.restresources;

package com.demo.restresources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import com.demo.model.User;

import atg.nucleus.GenericService;
import atg.service.jaxrs.RepresentationModel;
import atg.service.jaxrs.RestException;
import atg.service.jaxrs.annotation.Endpoint;
import atg.service.jaxrs.annotation.RestResource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestResource(id = "com.demo.restresource")
@Api(value = "Demo Endpoints")
@Path("/demo")
public class UserRestResource extends GenericService {

    @GET
    @Path(value = "/users/{userId}")
    @Endpoint(id = "/demo/users/{userId}#GET", isSingular=true, filterId="demo.user-default")
    @ApiOperation(value = "Returns a specific user's details.")
    public RepresentationModel getUser(@ApiParam(required = true) @PathParam(value = "userId") String pUserId) throws RestException {
        if (this.isLoggingInfo()) {
            this.logInfo("Entered getUser endpoint, user Id : " + pUserId);
        }
        User user = new User();
        user.setId(pUserId);
        user.setName("Doe");
        return new RepresentationModel.Builder().state(user).build();
    }
}


2. Create the model class User.java

package com.demo.model;

public class User {

    private String id;
    private String name;
   
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
   
}


3. Create component properties file
#com.demo.restresources.UserRestResources.properties
$class=com.demo.restresources.UserRestResource
$classloader=/atg/dynamo/service/jaxrs/JerseyClassLoaderService


4. Register the nuclues component
#/atg/dynamo/service/jaxrs/RestResourceRegistry.properties
nucleusRestResources+=\
    /com/demo/restresources/UserRestResource

5. Create the Payload schema filter
#/atg/dynamo/service/payloadschema/payloadSchema.xml
<?xml version="1.0" encoding="UTF-8"?>
<payload-schemas xml-combine="append">
    <schema id="demo.user-default">
        <untyped-bean/>
        <property name="id" />
        <property name="name" />
    </schema>
</payload-schemas>


6. Register the resource and classloader
#/atg/dynamo/service/jaxrs/JerseyClassLoaderService.properties
childFirstPrefixes+=com/demo/restresources
classpathFiles+=\
  {appModuleResource?moduleID=MyModule&resourceURI=lib/demo-jersey-classloader.jar}


7. Update the ant script to create the class loader
    <target name="demo-jerseyclassloader-jar">
      <!-- Make a jar file with misc override classes. -->
        <jar
            jarfile="lib/demo-jersey-classloader.jar"
            basedir="bin"
            includes="
            com/demo/restresources/UserRestResource.class">
        </jar>
    </target>

8. Include the above ant target as part of build process


Wednesday, December 14, 2016

Blank CRS Home Page when running on Endeca

CRS home page is a endeca page and gets the content from the Experience Manager.
If there is no default site id configured in XM, then CRS home page will be blank.
To add the default site, follow below steps.

1. C:\Endeca\Apps\<App-name>\control\runcommand.bat IFCR exportApplication <App-name>
2. Unzip and edit C:\Endeca\Apps\<App-name>\control\<App-name>\pages\_.json to add "defaultSiteId": "/storeSiteUS"

{
    "ecr:createDate": "2015-11-26T22:15:35.205-06:00",
    "ecr:type": "page-root",
    "defaultSiteId": "/storeSiteUS"
}

3. C:\Endeca\Apps\<App-name>\control>C:\Endeca\Apps\<App-name>\control\runcommand.bat IFCR importApplication <App-name>


Friday, November 11, 2016

Adding New Pricing Calculator

The below example shows on how to add a new item price precalculator to calculate the wholesale price.


  1. Create a new class ItemWholeSalePriceCalculator extending ItemPriceCalculator class similar to ItemListPriceCalculator to calculate the whole sale price of each commerceItem.

public class ItemWholeSalePriceCalculator extends ItemPriceCalculator{
  protected void priceItem(double pPrice, ItemPriceInfo pPriceQuote, CommerceItem pItem,
                           RepositoryItem pPricingModel, Locale pLocale,
                           RepositoryItem pProfile, Map pExtraParameters)
    throws PricingException{
      double totalPrice = NumberUtils.multiply(pPrice, pItem.getQuantityDerivedAsFloatingPoint()).doubleValue();
      pPriceQuote.setAmount(totalPrice);
  }
}

2. Create a new component ItemWholeSalePriceCalculator similar to ItemListPriceCalculator component to handle above class.
$class=atg.commerce.pricing.ItemWholeSalePriceCalculator

loggingIdentifier=ItemWholeSalePriceCalculator
pricePropertyName=wholeSalePrice
requirePriceValue=false
priceFromCatalogRef=true

pricingTools=/atg/commerce/pricing/PricingTools


3. Override the values of ItemPricingEngine component to add the new calculator ItemWholeSalePriceCalculator.

/atg/commerce/pricing/ItemPricingEngine.properties
preCalculators+=\
calculators/ItemWholeSalePriceCalculator


Tuesday, October 11, 2016

PermissionDeniedException while creating site agents in BCC

When creating site agents in BCC, there is error in logs:
Caused by: CONTAINER:atg.repository.RepositorySecurityException; SOURCE:atg.security.PermissionDeniedException: You do not have read access to the project item descriptor.
        at atg.adapter.secure.GenericSecuredRepository.checkAccess(GenericSecuredRepository.java:457) [_DAS_slib_sclasses.jar:]
        at atg.adapter.secure.GenericSecuredRepositoryView.executeQuery(GenericSecuredRepositoryView.java:401) [_DAS_slib_sclasses.jar:]
        at atg.repository.rql.RqlStatement.executeQuery(RqlStatement.java:227) [_DAS_slib_sclasses.jar:]
        at atg.repository.tojava.runtime.RJSupport.executeRqlStatementForOne(RJSupport.java:1121) [_DAS_slib_sclasses.jar:]
        ... 42 more


This is caused because there user selected the project and then trying to create the agents.
The workaround is logout and login directly to <bcc-url>/atg/atgadmin and create the agents.