Wednesday, August 8, 2018

Updating WebLogic Datasource properties WSLT Offline

When we have multiple environments for different releases, it is very common to change the weblogic database properties to point corresponding database. Instead of going to Weblogic console and doing it manually, it can be done using WSLT scripts offline quickly.
The below scripts and properties file is used to update the datasource properties.

/u01/scripts/update-datasource.py

from java.io import FileInputStream

propInputStream = FileInputStream("/u01/scripts/ds.properties")
configProps = Properties()
configProps.load(propInputStream)

dsnames= configProps.get("ds.names")

readDomain(configProps.get("domain.path"))
dsName=''
for member in dsnames:
if member == ",":
print 'updating the password for ' + dsName
cd('/JDBCSystemResource/'+dsName+'/JdbcResource/'+dsName+'/JDBCDriverParams/NO_NAME_0')
set('PasswordEncrypted', encrypt(configProps.get("ds."+dsName+".pwd")))
set('URL',configProps.get("ds."+dsName+".url"))
cd('Properties/NO_NAME_0')
cd('Property')
cd('user')
set('Value', configProps.get("ds."+dsName+".username"))
dsName=''
else:
dsName=dsName+member
updateDomain()
exit()


/u01/scripts/ds.properties
domain.path=/u01/oracle/user_projects/domains/base_domain

ds.names=appatg,appcat,appmarket,appnotme,
ds.appatg.username=STR01_ATGAPP
ds.appatg.pwd=tst1to5appusers
ds.appatg.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=zlt13574.vci.att.com)(PORT=1524)))(CONNECT_DATA=(SERVICE_NAME=t1c4d857)))

ds.appcat.pwd=catpwd
ds.appmarket.pwd=marketpwd
ds.appnotme.pwd=notmepwd

/u01/scripts/update-datasource.sh
#!/bin/bash
cd /u01/oracle/user_projects/domains/base_domain

/u01/oracle/wlserver/common/bin/wlst.sh /u01/scripts/ds.py
cd -

Execute the script:
$ /u01/scripts/update-datasources.sh


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