update junit to recheck for snapshot file
[aai/graphadmin.git] / src / main / scripts / run_SendMigrationNotification.sh
1 #!/bin/bash
2
3 ###
4 # ============LICENSE_START=======================================================
5 # org.onap.aai
6 # ================================================================================
7 # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12
13 #      http://www.apache.org/licenses/LICENSE-2.0
14
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END=========================================================
21 ###
22
23 COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
24 . ${COMMON_ENV_PATH}/common_functions.sh
25
26
27 start_date;
28 check_user;
29 source_profile;
30
31 INPUT_PATH=$1
32
33 if [ ! -d "$INPUT_PATH" ]; then
34     echo "Input directory $INPUT_PATH does not exist!!";
35     exit
36 fi
37
38 if [ $(ls ${INPUT_PATH}/* 2> /dev/null | wc -l) -eq 0 ]; then
39     echo "Input directory $INPUT_PATH does not contain any migration files!!";
40     exit
41 fi
42
43 INPUT_DIR_FOR_JAVA=${INPUT_PATH}/combined
44 mkdir -p "$INPUT_DIR_FOR_JAVA"
45 INPUT_FILE_FOR_JAVA=${INPUT_DIR_FOR_JAVA}/sorted_dmaap_files.txt
46 sort -g -k 1 -t '_' $(find ${INPUT_PATH}/* -maxdepth 0 -type f) | awk -F '_' '{ print $2"_"$3; }' > $INPUT_FILE_FOR_JAVA
47
48 shift
49
50 ARGS="-c ${PROJECT_HOME}/resources/etc/appprops/janusgraph-realtime.properties --inputFile $INPUT_FILE_FOR_JAVA"
51
52 if [ -f "$PROJECT_HOME/resources/application.properties" ]; then
53     # Get the application properties file and look for all lines
54     # starting with either jms dmaap or niws
55     # Turn them into system properties and export JAVA_PRE_OPTS so
56     # execute spring jar will get those values
57     # This is only needed since dmaap is used by run_migrations
58     JAVA_PRE_OPTS=$(egrep '^jms.bind.address' $PROJECT_HOME/resources/application.properties | cut -d"=" -f2- |  sed 's/^\(.*\)$/-Dactivemq.tcp.url=\1/g' | tr '\n' ' ');
59     export JAVA_PRE_OPTS;
60 fi;
61
62 execute_spring_jar org.onap.aai.util.SendMigrationNotificationsMain ${PROJECT_HOME}/resources/migration-logback.xml ${ARGS} "$@"
63 end_date;
64 exit 0