

from java.util import Properties
from java.io import FileInputStream
import jarray
import sys
import getopt
import wlst92 as wlst


def extendDomainWithWorklist81Compatibility(domaindir,weblogicHome ):
	print ' reading domain '+domaindir
	wlst.readDomain(domaindir)
	print 'adding worklist81 template'
	wlst.addTemplate(weblogicHome+'/common/templates/applications/wli_worklist81x.jar')
	print 'updating domain'
	wlst.updateDomain() 
	print 'closing domain'
	wlst.closeDomain() 
	print 'domain extended successfully with worklist81compat'




#
# main
#
def main():
	global domaindir, username, password, url, weblogicHome
	try:
		opts, args = getopt.getopt( sys.argv[1:], "n:p:u:d:w:", "" )
	except getopt.GetoptError:
		print "invalid option"
		sys.exit(2)
		
	for o, a in opts:
		if o == "-n":
			username = a
		if o == "-p":
			password = a
		if o == "-u":
			url = a
		if o == "-d":
			domaindir = a
		if o == "-w":
			weblogicHome = a	
			
	if ((domaindir == None) or (weblogicHome == None) ):
		print "Bad or Missing parameters"
		sys.exit(2)
	
	extendDomainWithWorklist81Compatibility(domaindir,weblogicHome )

# invoke main
if __name__ == "__main__":
    main()