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