def updateApplicationDom(dom):
    cellName = WebSphere.AdminControl.getCell()
    application = parseApplication(dom)
    comment = ""
    moduleTargets = {}
    applicationAttributes = []
    error = 0
    if not checkIfAppNameExists(application.name):
        comment = "Application does not exist on %s" % cellName
        error = 1
    else:
        comment = "Validated on %s" % cellName
        moduleTargets, applicationAttributes = getModuleConfigs(application)

    error += updateApplicationModel(dom, moduleTargets, applicationAttributes, comment)
    return error
def updateApplicationDom(dom):
    cellName = WebSphere.AdminControl.getCell()
    application = parseApplication(dom)
    comment = ""
    moduleTargets = {}
    applicationAttributes = []
    error = 0
    if not checkIfAppNameExists(application.name):
        comment = "Application does not exist on %s" % cellName
        error = 1
    else:
        comment = "Validated on %s" % cellName
        moduleTargets, applicationAttributes = getModuleConfigs(application)

    error += updateApplicationModel(dom, moduleTargets, applicationAttributes,
                                    comment)
    return error
def updateApplicationXMLs(distDir):
    if not os.path.isdir(distDir):
        msg = "readDistributionDirectory: ERROR: is not a directory, distDir=" + distDir
        fail(msg)
    if not os.path.exists(distDir):
        msg = "readDistributionDirectory: ERROR: does not exist, distDir=" + distDir
        fail(msg)
    files = glob.glob(distDir + "/*.xml.in")
    xml.dom.javadom.Node.namespaceURI = None
    impl = xml.dom.javadom.XercesDomImplementation()
    for file in files:
        dom = impl.buildDocumentFile(file)
        error = updateApplicationDom(dom)
        applicationModel = parseApplication(dom)
        file = file[0:len(file) - 3]
        stream = open(file, "wt")
        xml.dom.ext.PrettyPrint(dom, stream)
        stream.close()
        if error > 0:
            os.rename(file, file + ".err")
            print "GENERATE ERR " + file + ".err for " + applicationModel.name + " at " + applicationModel.file
        else:
            print "GENERATE OK " + file + " for " + applicationModel.name + " at " + applicationModel.file
    print "NODE SYNC STATUS: %s" % nodeSyncStatus
def updateApplicationXMLs(distDir):
    if not os.path.isdir(distDir):
        msg = "readDistributionDirectory: ERROR: is not a directory, distDir=" + distDir
        fail(msg)
    if not os.path.exists(distDir):
        msg = "readDistributionDirectory: ERROR: does not exist, distDir=" + distDir
        fail(msg)
    files = glob.glob(distDir + "/*.xml.in")
    xml.dom.javadom.Node.namespaceURI = None
    impl = xml.dom.javadom.XercesDomImplementation()
    for file in files:
        dom = impl.buildDocumentFile(file)
        error = updateApplicationDom(dom)
        applicationModel = parseApplication(dom)
        file = file[0:len(file) - 3]
        stream = open(file, "wt")
        xml.dom.ext.PrettyPrint(dom, stream)
        stream.close()
        if error > 0:
            os.rename(file, file + ".err")
            print "GENERATE ERR " + file + ".err for " + applicationModel.name + " at " + applicationModel.file
        else:
            print "GENERATE OK " + file + " for " + applicationModel.name + " at " + applicationModel.file
    print "NODE SYNC STATUS: %s" % nodeSyncStatus