Sunday, August 5, 2012

WLST check for existence of a JMSModule

Often you must CONDITIONALLY do an operation based on the existence/non existence of a resource:

def deleteJMSModule(jmsModule):
    myBean = getMBean('/SystemResources/' + jmsModule)
    if myBean is not None:  
        edit()
        startEdit()
        try:
            cmo.destroyJMSSystemResource(getMBean('/SystemResources/' + jmsModule))
            print "deleted JMSModule " + jmsModule
            validate()    
            save()
            activate()
        except:
            print('unable to delete preexisting JMSModule ' + jmsModule)
            dumpStack()
            undo('true', 'y')
            cancelEdit('y')
    else:
        print 'JMSModule ' + jmsModule + ' does not exist, I will not delete it'



make sure you check for the existence of the MBean BEFORE you do the edit()... otherwise you will get an exception

No comments: