###
# Licensed Materials - Property of IBM* and/or HCL**
# (c) Copyright IBM Corporation 2017. All Rights Reserved.
# (c) Copyright HCL Technologies Ltd. 2018. All Rights Reserved.
#
# U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
# GSA ADP Schedule Contract with IBM Corp.
#
# * Trademark of International Business Machines
# ** Trademark of HCL Technologies Limited
#
# Filename: wsadminLib.jython
#
#
###

import sys

propertiesFileName    = sys.argv[0]
configDataKey = ""
configDataValue = ""
optionsKey = ""
optionsValue = ""
filterMechanism = ""
selectedSubTypesKey = ""
selectedSubTypesValue = ""
zipFileName = ""
for index in range(len(sys.argv)):
    if sys.argv[index] == "-conf":
        configDataKey = sys.argv[index + 1]
        configDataValue = sys.argv[index + 2]
    if sys.argv[index] == "-opt":
        optionsKey = sys.argv[index + 1]
        optionsValue = sys.argv[index + 2]
    if sys.argv[index] == "-filter":
        filterMechanism = sys.argv[index + 1]
    if sys.argv[index] == "-subKey":
        selectedSubTypesKey = sys.argv[index + 1]
    if sys.argv[index] == "-subValue":
        selectedSubTypesValue = sys.argv[index + 1]
    if sys.argv[index] == "-allOpt":
        filterMechanism = sys.argv[index + 1]
    if sys.argv[index] == "-zip":
        zipFileName = sys.argv[index + 1]


parametersList = []
parameters=""

parametersList.append("[-propertiesFileName " + propertiesFileName)

if (configDataKey and configDataValue):
    parametersList.append(" -configData " + str(configDataKey) + "=" + str(configDataValue))

if (optionsKey and optionsValue):
    parametersList.append(" -options [[" + str(optionsKey) + " " + str(optionsValue) +"]]")

if (filterMechanism):
    parametersList.append(" -filterMechanism " + str(filterMechanism))

if (selectedSubTypesKey):
    parametersList.append(" -selectedSubTypes [" + str(selectedSubTypesKey))

if (selectedSubTypesValue):
    parametersList.append(" " + str(selectedSubTypesValue) + "]")
elif(selectedSubTypesKey):
    parametersList.append("]")

if (zipFileName):
    parametersList.append(" -zipFileName " + str(zipFileName) + "]")

parametersList.append("]")

if (parametersList):
    parameters = ''.join(parametersList)

AdminTask.extractConfigProperties(parameters)
