From 9220f729873a7be6455f832468f5090ccd2a25cb Mon Sep 17 00:00:00 2001 From: "Kajur, Harish (vk250x)" Date: Mon, 13 Aug 2018 02:44:43 -0400 Subject: Update traversal to use schema ingest library Update the traversal microservice to use the ingest library to make the application more model driven Issue-ID: AAI-1465 Change-Id: Ifcf56b5d0e7f25ce2bc735b3186e09bc28234100 Signed-off-by: Kajur, Harish (vk250x) --- aai-traversal/src/main/scripts/putTool.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'aai-traversal/src/main/scripts/putTool.sh') diff --git a/aai-traversal/src/main/scripts/putTool.sh b/aai-traversal/src/main/scripts/putTool.sh index 6630d8f..593d0c9 100644 --- a/aai-traversal/src/main/scripts/putTool.sh +++ b/aai-traversal/src/main/scripts/putTool.sh @@ -50,12 +50,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: query?format=xxxx customquery.json (possible formats are simple, raw, console, count, graphson, id, pathed, resource and resource_and_url) - 4. Adding the optional HTTP Response code will allow the script to ignore HTTP failure codes that match the input parameter. - 5. Adding the optional "-display" argument will display all data returned from the request, instead of just a response code. - + 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 @@ -130,24 +128,30 @@ else fi fi +fname=$JSONFILE +if [ -f /tmp/$(basename $JSONFILE) ]; then + fname=/tmp/$(basename $JSONFILE) +elif [ ! -f $JSONFILE ]; then + echo "The file $JSONFILE does not exist" + exit -1 +fi + if [ $MISSING_PROP = false ]; then if [ $USEBASICAUTH = false ]; then AUTHSTRING="--cert $PROJECT_HOME/resources/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/resources/etc/auth/aaiClientPrivateKey.pem" else AUTHSTRING="-u $CURLUSER:$CURLPASSWORD" fi - if [ $RETURNRESPONSE = true ]; then - curl --request PUT -sL -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE | python -mjson.tool + curl --request PUT -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE | jq '.' RC=$? else - result=`curl --request PUT -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "Content-Type: application/json" -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -T $JSONFILE $RESTURL$RESOURCE` + result=`curl --request PUT -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" -H "Content-Type: application/json" -T $fname $RESTURL$RESOURCE` #echo "result is $result." RC=0; if [ $? -eq 0 ]; then case $result in +([0-9])?) - #if [[ "$result" -eq 412 || "$result" -ge 200 && $result -lt 300 ]] if [[ "$result" -ge 200 && $result -lt 300 ]] then echo "PUT result is OK, $result" @@ -184,4 +188,4 @@ else fi echo `date` " Done $0, returning $RC" -exit $RC +exit $RC \ No newline at end of file -- cgit 1.2.3-korg