Friday, July 19, 2013

Lint and CheckStyle for OSB

Export your sbconfig.jar and unjar it
find . -name *.ProxyService > allproxies.txt
wlst > osblintresult.txt

from xml.dom import minidom

f = open('allproxies.txt')
allproxies = [line.strip() for line in f ]

for aproxy in allproxies:
    print "processing", aproxy
    xmldoc = minidom.parse(aproxy)
    logs = xmldoc.getElementsByTagNameNS("", 'log')    
    for log in logs:
        logLevel = log.getElementsByTagNameNS("", 'logLevel')[0]
        xqueryTexts = log.getElementsByTagNameNS("", 'xqueryText')
        if len(xqueryTexts) > 0: 
            xqueryText = xqueryTexts[0]
            logLevelString = logLevel.childNodes[0].nodeValue
            variableString = xqueryText.childNodes[0].nodeValue
            print aproxy, "logLevel", logLevelString, "variable", variableString
            if "fault" in variableString and logLevelString == "debug":
                print "OSBLINTERROR fault with debug level"
            print "OSBLINTERROR missing xqueryText"

The check above tests that all fault variables are logged with level different from debug.

No comments: