3c7f1bfc4b3a4f5cd9b3b820c058a4c28af6bb2c
[aai/traversal.git] / aai-traversal / src / main / scripts / install / updateQueryData.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 PROGNAME=$(basename $0)
25 PROJECT_HOME=/opt/app/aai-traversal
26 OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
27
28 TS=$(date "+%Y-%m-%d %H:%M:%S")
29
30 CHECK_USER="aaiadmin"
31 userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
32 if [ "${userid}" != $CHECK_USER ]; then
33     echo "You must be  $CHECK_USER to run $0. The id used $userid."
34     exit 1
35 fi 
36
37 error_exit () {
38         echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" 1>&2
39         echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" >> $OUTFILE
40 #       exit ${2:-"1"}
41 }
42
43 j=0
44 for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/widget-model-json/*.json|sort -f`
45 do
46 j=$(expr "$j" + 1)
47 filename=$(basename $filepath)
48 echo "Begin putTool for widget $filename" | tee -a $OUTFILE
49 vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2`
50 # last parameter will skip put if it exists
51 resource=service-design-and-creation/models/model/$vers
52 $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
53 echo "End putTool for widget $filename" | tee -a $OUTFILE
54 done
55
56 j=0
57 for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/named-query-json/*.json|sort -f`
58 do
59 j=$(expr "$j" + 1)
60 filename=$(basename $filepath)
61 echo "Begin putTool for named-query $filename" | tee -a $OUTFILE
62 vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2`
63 # last parameter will skip put if it exists
64 resource=service-design-and-creation/named-queries/named-query/$vers
65 $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
66 echo "End putTool for named-query $filename" | tee -a $OUTFILE
67 done
68
69 j=0
70 for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/resource-model-json/*.json|sort -f`
71 do
72 j=$(expr "$j" + 1)
73 filename=$(basename $filepath)
74 echo "Begin putTool for resource model $filename" | tee -a $OUTFILE
75 vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2`
76 # last parameter will skip put if it exists
77 resource=service-design-and-creation/models/model/$vers
78 $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
79 echo "End putTool for resource model $filename" | tee -a $OUTFILE
80 done
81
82 j=0
83 for filepath in `ls $PROJECT_HOME/bundleconfig/etc/scriptdata/service-model-json/*.json|sort -f`
84 do
85 j=$(expr "$j" + 1)
86 filename=$(basename $filepath)
87 echo "Begin putTool for service model $filename" | tee -a $OUTFILE
88 vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2`
89 # last parameter will skip put if it exists
90 resource=service-design-and-creation/models/model/$vers
91 $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
92 echo "End putTool for service model $filename" | tee -a $OUTFILE
93 done
94
95 echo "$PROGNAME completed ${TS}" | tee -a $OUTFILE
96 echo "See output and error file: $OUTFILE"
97
98 exit 0