From 4c4412642e40a92bebd26f2966bc72619e16ae79 Mon Sep 17 00:00:00 2001 From: Venkata Harish K Kajur Date: Thu, 18 Jan 2018 02:25:31 -0500 Subject: Sync up the latest logging code changes Issue-ID: AAI-493 Change-Id: I778acf7726b1f9881dee62b128b1fbc457bf7a7e Signed-off-by: Venkata Harish K Kajur --- aai-resources/src/main/scripts/putTool.sh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'aai-resources/src/main/scripts/putTool.sh') diff --git a/aai-resources/src/main/scripts/putTool.sh b/aai-resources/src/main/scripts/putTool.sh index dfa9b37..b5ad862 100644 --- a/aai-resources/src/main/scripts/putTool.sh +++ b/aai-resources/src/main/scripts/putTool.sh @@ -46,9 +46,10 @@ display_usage() { cat < + 1. Usage: putTool.sh 2. This script requires two arguments, a resource path and a file path to a json file containing the payload. 3. Example: resource-path and payload for a particular customer is: business/customers/customer/JohnDoe customerpayload.json + 4. Adding the optional "-display" argument will display all data returned from the request. EOF } if [ $# -eq 0 ]; then @@ -87,6 +88,13 @@ prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties log_dir=$PROJECT_HOME/logs/misc today=$(date +\%Y-\%m-\%d) +RETURNRESPONSE=false +if [ ${#} -ne 2 ]; then + if [ "$3" = "-display" ]; then + RETURNRESPONSE=true + fi +fi + MISSING_PROP=false RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"` if [ -z $RESTURL ]; then @@ -117,10 +125,14 @@ if [ $MISSING_PROP = false ]; then else AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" fi - result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE` - #echo "result is $result." - RC=0; - if [ $? -eq 0 ]; then + if [ $RETURNRESPONSE = true ]; then + curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool + RC=$? + else + result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE` + #echo "result is $result." + RC=0; + if [ $? -eq 0 ]; then case $result in +([0-9])?) if [[ "$result" -ge 200 && $result -lt 300 ]] @@ -148,10 +160,11 @@ if [ $MISSING_PROP = false ]; then ;; esac - else + else echo "FAILED to send request to $RESTURL" RC=-1 - fi + fi + fi else echo "usage: $0 resource file [expected-failure-codes]" RC=-1 -- cgit 1.2.3-korg