2d19a9c6ef73c6712d0a8424da1ef7809c4be12e
[aai/traversal.git] / aai-traversal / src / main / scripts / deleteNamedQuery.sh
1 #!/bin/ksh
2 #
3 # ============LICENSE_START=======================================================
4 # org.onap.aai
5 # ================================================================================
6 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
7 # ================================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
11 #
12 #    http://www.apache.org/licenses/LICENSE-2.0
13 #
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END=========================================================
20 #
21 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 #
23
24 #
25 # This script deletes the named query in bundleconfig/etc/scriptdata/named-query-json directory
26 #
27
28 PROGNAME=$(basename $0)
29 <<<<<<< HEAD
30 OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
31 =======
32 OUTFILE=/opt/app/aai-traversal/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
33 >>>>>>> codecloud/release/1802
34 #OUTFILE=/c/temp/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
35
36 TS=$(date "+%Y-%m-%d %H:%M:%S")
37
38 CHECK_USER="aaiadmin"
39 userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
40 if [ "${userid}" != $CHECK_USER ]; then
41     echo "You must be  $CHECK_USER to run $0. The id used $userid."
42     exit 1
43 fi 
44
45 error_exit () {
46         echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" 1>&2
47         echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" >> $OUTFILE
48 #       exit ${2:-"1"}
49 }
50
51 j=0
52 <<<<<<< HEAD
53 for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
54 =======
55 for filepath in `ls /opt/app/aai-traversal/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
56 >>>>>>> codecloud/release/1802
57 #for filepath in `ls /c/sources/aai/aaigitnew/bundleconfig-local/etc/scriptdata/named-query-json/*.json|sort -f`
58 do
59 j=$(expr "$j" + 1)
60 filename=$(basename $filepath)
61 echo "Begin deleteTool for named-query $filename" | tee -a $OUTFILE
62 vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2`
63 resource=service-design-and-creation/named-queries/named-query/$vers
64 <<<<<<< HEAD
65 echo "y" | $PROJECT_HOME/scripts/deleteTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
66 =======
67 echo "y" | /opt/app/aai-traversal/scripts/deleteTool.sh $resource >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
68 >>>>>>> codecloud/release/1802
69 echo "End deleteTool for named-query $filename" | tee -a $OUTFILE
70 done
71
72 echo "$PROGNAME completed ${TS}" | tee -a $OUTFILE
73 echo "See output and error file: $OUTFILE"
74
75 exit 0