summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-07-02 10:00:57 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2024-07-04 11:55:05 +0200
commit9e6101e4b225804fbe38f40ebd49516e5e10ecce (patch)
tree53fda1055ad1ab26c2e98a0166aca860e8c8fc47
parent589066bc5238e8d86fe893949d1a48cfdc16309b (diff)
Use eclipse-temurin:8-jre-alpine docker base image in aai-traversal
- replace aai-common base image with plain java 8 jre - remove custom folders and users to simplify setup - fix janino, guava and activemq vulnerabilities - remove apache httpclient, jsonassert, aaf-cadi and spring-test dependencies Issue-ID: AAI-3913 Change-Id: Icca637b5adb8e9a480912c4e2b7d9e83ee3e29ba Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
-rw-r--r--aai-traversal/pom.xml74
-rw-r--r--aai-traversal/src/main/docker/Dockerfile32
-rw-r--r--aai-traversal/src/main/docker/aai.sh3
-rw-r--r--aai-traversal/src/main/docker/docker-entrypoint.sh41
-rw-r--r--aai-traversal/src/main/scripts/common_functions.sh15
-rw-r--r--aai-traversal/src/main/scripts/deleteNamedQuery.sh9
-rw-r--r--aai-traversal/src/main/scripts/deleteTool.sh18
-rw-r--r--aai-traversal/src/main/scripts/getTool.sh12
-rwxr-xr-x[-rw-r--r--]aai-traversal/src/main/scripts/install/updateQueryData.sh49
-rw-r--r--aai-traversal/src/main/scripts/putTool.sh114
-rw-r--r--pom.xml2
-rw-r--r--version.properties2
12 files changed, 119 insertions, 252 deletions
diff --git a/aai-traversal/pom.xml b/aai-traversal/pom.xml
index 99e5c2d..b11021d 100644
--- a/aai-traversal/pom.xml
+++ b/aai-traversal/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.onap.aai.traversal</groupId>
<artifactId>traversal</artifactId>
- <version>1.14.3-SNAPSHOT</version>
+ <version>1.14.4-SNAPSHOT</version>
</parent>
<groupId>org.onap.aai.traversal</groupId>
<artifactId>aai-traversal</artifactId>
@@ -102,12 +102,11 @@
<javax.servlet.version>4.0.1</javax.servlet.version>
<antlr.version>4.9.3</antlr.version>
<keycloak.version>11.0.2</keycloak.version>
+ <activemq.version>5.16.7</activemq.version>
<micrometer.version>1.6.6</micrometer.version>
<mockito.core.version>3.4.0</mockito.core.version>
<testcontainers.version>1.6.1</testcontainers.version>
- <netty.handler.version>4.1.63.Final</netty.handler.version>
- <netty.version>4.1.63.Final</netty.version>
<!-- End of Default ONAP Schema Properties -->
<!-- Integration tests will be skipped by default. Could be enabled here or by -DskipITs=false-->
@@ -450,10 +449,7 @@
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <version>3.1.12</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
@@ -589,13 +585,6 @@
</exclusion>
</exclusions>
</dependency>
- <!-- Do not use the jersey-client since jersey client 1.0 version clashes
- with jersey 2 which we are using -->
- <!-- Use this to make http requests instead of jersey 1.0 client -->
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
<dependency>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-rest</artifactId>
@@ -606,17 +595,6 @@
</exclusion>
</exclusions>
</dependency>
- <dependency>
- <groupId>org.skyscreamer</groupId>
- <artifactId>jsonassert</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>com.vaadin.external.google</groupId>
- <artifactId>android-json</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
<!-- Explicitly stating the security spring framework and exclude the bouncy
castle since that is somehow overwriting our p12 file decryption that's built
into java security This will cause the password is incorrect This needs to
@@ -633,11 +611,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-handler</artifactId>
- <version>${netty.handler.version}</version>
- </dependency>
- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
@@ -672,38 +645,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
- </dependency>
- <!-- TODO: Migrate tests to junit 5 and remove this dependency -->
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
<exclusions>
- <exclusion>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- </exclusion>
+ <exclusion>
+ <groupId>com.vaadin.external.google</groupId>
+ <artifactId>android-json</artifactId>
+ </exclusion>
</exclusions>
- </dependency>
- <dependency>
- <groupId>org.onap.aaf.authz</groupId>
- <artifactId>aaf-cadi-aaf</artifactId>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- <version>${netty.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-test</artifactId>
- <scope>test</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
@@ -761,6 +709,12 @@
<version>${keycloak.version}</version>
<scope>test</scope>
</dependency>
+ <!-- TODO: Migrate tests to junit 5 and remove this dependency -->
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
diff --git a/aai-traversal/src/main/docker/Dockerfile b/aai-traversal/src/main/docker/Dockerfile
index 0186e25..e17fa90 100644
--- a/aai-traversal/src/main/docker/Dockerfile
+++ b/aai-traversal/src/main/docker/Dockerfile
@@ -1,28 +1,14 @@
-FROM @aai.docker.namespace@/aai-common-@aai.base.image@:@aai.base.image.version@
+FROM eclipse-temurin:8-jre-alpine
+# curl is used in the putTool script
+# (PUT's can't be done using the busybox wget)
+RUN apk --no-cache add curl
-USER root
+USER nobody
+ENV SERVER_PORT=8446
+EXPOSE ${SERVER_PORT}
-RUN mkdir -p /opt/aaihome/aaiadmin /opt/aai/logroot/AAI-GQ \
- /opt/app/aai-traversal \
- && chown -R aaiadmin:aaiadmin /opt/aaihome/aaiadmin /opt/aai/logroot/AAI-GQ \
- /opt/app/aai-traversal /etc/profile.d /opt/app /opt/aai/logroot \
- /etc/profile.d \
- /opt/app
-
-VOLUME /tmp
-VOLUME /opt/tools
-
-HEALTHCHECK --interval=40s --timeout=10s --retries=3 CMD nc -z -v localhost 8446 || exit 1
-
-# Add the proper files into the docker image from your build
WORKDIR /opt/app/aai-traversal
-COPY --chown=aaiadmin:aaiadmin /maven/aai-traversal/ .
-
-USER aaiadmin
+COPY --chown=nobody:nobody /maven/aai-traversal/ .
-ENV AAI_BUILD_VERSION @aai.docker.version@
-# Expose the ports for outside linux to use
-# 8446 is the important one to be used
-EXPOSE 8446
-ENTRYPOINT ["/bin/bash", "/opt/app/aai-traversal/docker-entrypoint.sh"] \ No newline at end of file
+ENTRYPOINT ["/bin/sh", "/opt/app/aai-traversal/docker-entrypoint.sh"]
diff --git a/aai-traversal/src/main/docker/aai.sh b/aai-traversal/src/main/docker/aai.sh
index 8cda4f0..412586e 100644
--- a/aai-traversal/src/main/docker/aai.sh
+++ b/aai-traversal/src/main/docker/aai.sh
@@ -30,7 +30,8 @@ if [ -z $JAVA_HOME ] && [ $(grep -i "ID=ubuntu" /etc/os-release | wc -w) -eq 1 ]
fi
# set app related env
-export PROJECT_HOME=/opt/app/aai-traversal
+: ${PROJECT_HOME:=/opt/app/aai-traversal}
+export PROJECT_HOME=$PROJECT_HOME
export AAIENV=dev
export PROJECT_OWNER=aaiadmin
export PROJECT_GROUP=aaiadmin
diff --git a/aai-traversal/src/main/docker/docker-entrypoint.sh b/aai-traversal/src/main/docker/docker-entrypoint.sh
index 7d3ca9a..be29460 100644
--- a/aai-traversal/src/main/docker/docker-entrypoint.sh
+++ b/aai-traversal/src/main/docker/docker-entrypoint.sh
@@ -7,9 +7,9 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,45 +28,12 @@ GROUP_ID=${LOCAL_GROUP_ID:-9001}
find /opt/app/ -name "*.sh" -exec chmod +x {} +
-if [ -f ${APP_HOME}/aai.sh ]; then
-
- ln -s bin scripts
- ln -s /opt/aai/logroot/AAI-GQ logs
- mv ${APP_HOME}/aai.sh /etc/profile.d/aai.sh
-
- chmod 755 /etc/profile.d/aai.sh
-
- scriptName=$1;
-
- if [ ! -z $scriptName ]; then
-
- if [ -f ${APP_HOME}/bin/${scriptName} ]; then
- shift 1;
- ${APP_HOME}/bin/${scriptName} "$@" || {
- echo "Failed to run the ${scriptName}";
- exit 1;
- }
- else
- echo "Unable to find the script ${scriptName} in ${APP_HOME}/bin";
- exit 1;
- fi;
-
- exit 0;
- fi;
-fi;
-
if [ -z ${DISABLE_UPDATE_QUERY} ]; then
UPDATE_QUERY_RAN_FILE="updateQueryRan.txt";
/opt/app/aai-traversal/bin/install/updateQueryData.sh
touch ${UPDATE_QUERY_RAN_FILE};
fi
-mkdir -p /opt/app/aai-traversal/logs/gc
-
-if [ -f ${APP_HOME}/resources/aai-traversal-swm-vars.sh ]; then
- source ${APP_HOME}/resources/aai-traversal-swm-vars.sh;
-fi;
-
MIN_HEAP_SIZE=${MIN_HEAP_SIZE:-512m};
MAX_HEAP_SIZE=${MAX_HEAP_SIZE:-1024m};
MAX_METASPACE_SIZE=${MAX_METASPACE_SIZE:-512m};
@@ -105,10 +72,6 @@ JAVA_OPTS="${PRE_JAVA_OPTS} -DAJSC_HOME=$APP_HOME";
JAVA_OPTS="${JAVA_OPTS} -Dserver.port=${SERVER_PORT}";
JAVA_OPTS="${JAVA_OPTS} -DBUNDLECONFIG_DIR=./resources";
JAVA_OPTS="${JAVA_OPTS} -Dserver.local.startpath=${RESOURCES_HOME}";
-JAVA_OPTS="${JAVA_OPTS} -DAAI_CHEF_ENV=${AAI_CHEF_ENV}";
-JAVA_OPTS="${JAVA_OPTS} -DSCLD_ENV=${SCLD_ENV}";
-JAVA_OPTS="${JAVA_OPTS} -DAFT_ENVIRONMENT=${AFT_ENVIRONMENT}";
-JAVA_OPTS="${JAVA_OPTS} -DAAI_BUILD_VERSION=${AAI_BUILD_VERSION}";
JAVA_OPTS="${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom";
JAVA_OPTS="${JAVA_OPTS} -Dlogback.configurationFile=./resources/logback.xml";
JAVA_OPTS="${JAVA_OPTS} -Dloader.path=$APP_HOME/resources";
diff --git a/aai-traversal/src/main/scripts/common_functions.sh b/aai-traversal/src/main/scripts/common_functions.sh
index 43de18c..6fb725a 100644
--- a/aai-traversal/src/main/scripts/common_functions.sh
+++ b/aai-traversal/src/main/scripts/common_functions.sh
@@ -1,22 +1,11 @@
-#!/bin/ksh
+#!/bin/sh
# Common functions that can be used throughout multiple scripts
# In order to call these functions, this file needs to be sourced
-# Checks if the user that is currently running is aaiadmin
-check_user(){
-
- userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
-
- if [ "${userid}" != "aaiadmin" ]; then
- echo "You must be aaiadmin to run $0. The id used $userid."
- exit 1
- fi
-}
-
# Sources the profile and sets the project home
source_profile(){
- PROJECT_HOME=/opt/app/aai-traversal
+ : ${PROJECT_HOME:=/opt/app/aai-traversal}
}
# Runs the spring boot jar based on which main class
diff --git a/aai-traversal/src/main/scripts/deleteNamedQuery.sh b/aai-traversal/src/main/scripts/deleteNamedQuery.sh
index 43aaae7..6213de3 100644
--- a/aai-traversal/src/main/scripts/deleteNamedQuery.sh
+++ b/aai-traversal/src/main/scripts/deleteNamedQuery.sh
@@ -1,4 +1,4 @@
-#!/bin/ksh
+#!/bin/sh
#
# ============LICENSE_START=======================================================
# org.onap.aai
@@ -31,13 +31,6 @@ OUTFILE=/opt/app/aai-traversal/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
TS=$(date "+%Y-%m-%d %H:%M:%S")
-CHECK_USER="aaiadmin"
-userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
-if [ "${userid}" != $CHECK_USER ]; then
- echo "You must be $CHECK_USER to run $0. The id used $userid."
- exit 1
-fi
-
error_exit () {
echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" 1>&2
echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" >> $OUTFILE
diff --git a/aai-traversal/src/main/scripts/deleteTool.sh b/aai-traversal/src/main/scripts/deleteTool.sh
index c347b0d..239563b 100644
--- a/aai-traversal/src/main/scripts/deleteTool.sh
+++ b/aai-traversal/src/main/scripts/deleteTool.sh
@@ -1,4 +1,4 @@
-#!/bin/ksh
+#!/bin/sh
#
# ============LICENSE_START=======================================================
# org.onap.aai
@@ -23,7 +23,7 @@
#
# The script is called with a resource to be deleted.
-# Uses aaiconfig.properties for authorization type and url.
+# Uses aaiconfig.properties for authorization type and url.
# It invokes a GET on the resource using curl and parses the resource-version.
# If found, prompts the user to continue and invokes DELETE using curl.
# responses in the range of 200 to 299 are considered successful
@@ -39,17 +39,11 @@ fi
echo `date` " Starting $0 for resource $RESOURCE"
XFROMAPPID="AAI-TOOLS"
-XTRANSID=`uuidgen`
-XTRANSID1=`uuidgen`
-
-userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
-if [ "${userid}" != "aaiadmin" ]; then
- echo "You must be aaiadmin to run $0. The id used $userid."
- exit 1
-fi
+XTRANSID="someUUID"
+XTRANSID1="someUUID"
-PROJECT_HOME=/opt/app/aai-traversal
+: ${PROJECT_HOME:=/opt/app/aai-traversal}
prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
@@ -98,7 +92,7 @@ if [ $MISSING_PROP = false ]; then
echo `date` " Done $0, returning -1"
exit -1
fi
-
+
result=`curl --request DELETE -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE?resource-version=$RESOURCEVERSION`
echo "result is $result."
RC=0;
diff --git a/aai-traversal/src/main/scripts/getTool.sh b/aai-traversal/src/main/scripts/getTool.sh
index 6db0914..f72120b 100644
--- a/aai-traversal/src/main/scripts/getTool.sh
+++ b/aai-traversal/src/main/scripts/getTool.sh
@@ -1,4 +1,4 @@
-#!/bin/ksh
+#!/bin/sh
#
# ============LICENSE_START=======================================================
# org.onap.aai
@@ -36,16 +36,10 @@ fi
echo `date` " Starting $0 for resource $RESOURCE"
XFROMAPPID="AAI-TOOLS"
-XTRANSID=`uuidgen`
-
-userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
-if [ "${userid}" != "aaiadmin" ]; then
- echo "You must be aaiadmin to run $0. The id used $userid."
- exit 1
-fi
+XTRANSID="someUUID"
-PROJECT_HOME=/opt/app/aai-traversal
+: ${PROJECT_HOME:=/opt/app/aai-traversal}
prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
diff --git a/aai-traversal/src/main/scripts/install/updateQueryData.sh b/aai-traversal/src/main/scripts/install/updateQueryData.sh
index 7b5d1b3..9884efe 100644..100755
--- a/aai-traversal/src/main/scripts/install/updateQueryData.sh
+++ b/aai-traversal/src/main/scripts/install/updateQueryData.sh
@@ -1,4 +1,4 @@
-#!/bin/ksh
+#!/bin/sh
#
# ============LICENSE_START=======================================================
# org.onap.aai
@@ -22,8 +22,8 @@
#
PROGNAME=$(basename $0)
-PROJECT_HOME=/opt/app/aai-traversal
-OUTFILE=$PROJECT_HOME/logs/misc/${PROGNAME}.log.$(date +\%Y-\%m-\%d)
+
+: ${PROJECT_HOME:=/opt/app/aai-traversal}
if [ "$1" = "--debug" ]; then
set -x;
@@ -31,16 +31,8 @@ fi;
TS=$(date "+%Y-%m-%d %H:%M:%S")
-CHECK_USER="aaiadmin"
-userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
-if [ "${userid}" != $CHECK_USER ]; then
- echo "You must be $CHECK_USER to run $0. The id used $userid."
- exit 1
-fi
-
error_exit () {
echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" 1>&2
- echo "${PROGNAME}: failed for ${1:-"Unknown error"} on cmd $2" >> $OUTFILE
# exit ${2:-"1"}
}
@@ -54,11 +46,11 @@ vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2`
# last parameter will skip put if it exists
resource=service-design-and-creation/models/model/$vers
if [ "$1" = "--debug" ]; then
- bash -x $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
-else
- $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+ sh -x $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
+else
+ $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
fi;
-echo "End putTool for widget $filename" | tee -a $OUTFILE
+echo "End putTool for widget $filename"
done
j=0
@@ -66,16 +58,16 @@ for filepath in `ls $PROJECT_HOME/resources/etc/scriptdata/named-query-json/*.js
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
-echo "Begin putTool for named-query $filename" | tee -a $OUTFILE
+echo "Begin putTool for named-query $filename"
vers=`grep named-query-uuid $filepath|cut -d':' -f2|cut -d'"' -f2`
# last parameter will skip put if it exists
resource=service-design-and-creation/named-queries/named-query/$vers
if [ "$1" = "--debug" ]; then
- bash -x $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+ bash -x $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
else
- $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+ $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
fi;
-echo "End putTool for named-query $filename" | tee -a $OUTFILE
+echo "End putTool for named-query $filename"
done
j=0
@@ -83,16 +75,16 @@ for filepath in `ls $PROJECT_HOME/resources/etc/scriptdata/resource-model-json/*
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
-echo "Begin putTool for resource model $filename" | tee -a $OUTFILE
+echo "Begin putTool for resource model $filename"
vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2`
# last parameter will skip put if it exists
resource=service-design-and-creation/models/model/$vers
if [ "$1" = "--debug" ]; then
- bash -x $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+ bash -x $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
else
- $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+ $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
fi;
-echo "End putTool for resource model $filename" | tee -a $OUTFILE
+echo "End putTool for resource model $filename"
done
j=0
@@ -100,19 +92,18 @@ for filepath in `ls $PROJECT_HOME/resources/etc/scriptdata/service-model-json/*.
do
j=$(expr "$j" + 1)
filename=$(basename $filepath)
-echo "Begin putTool for service model $filename" | tee -a $OUTFILE
+echo "Begin putTool for service model $filename"
vers=`grep model-invariant-id $filepath|cut -d':' -f2|cut -d'"' -f2`
# last parameter will skip put if it exists
resource=service-design-and-creation/models/model/$vers
if [ "$1" = "--debug" ]; then
- bash -x $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+ bash -x $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
else
- $PROJECT_HOME/scripts/putTool.sh $resource $filepath 412 >> $OUTFILE 2>&1 || error_exit "$resource $filepath" $j
+ $PROJECT_HOME/bin/putTool.sh $resource $filepath 412 2>&1 || error_exit "$resource $filepath" $j
fi;
-echo "End putTool for service model $filename" | tee -a $OUTFILE
+echo "End putTool for service model $filename"
done
-echo "$PROGNAME completed ${TS}" | tee -a $OUTFILE
-echo "See output and error file: $OUTFILE"
+echo "$PROGNAME completed ${TS}"
exit 0
diff --git a/aai-traversal/src/main/scripts/putTool.sh b/aai-traversal/src/main/scripts/putTool.sh
index 6f22067..28463f4 100644
--- a/aai-traversal/src/main/scripts/putTool.sh
+++ b/aai-traversal/src/main/scripts/putTool.sh
@@ -1,4 +1,4 @@
-#!/bin/ksh
+#!/bin/sh
#
# ============LICENSE_START=======================================================
# org.onap.aai
@@ -78,16 +78,11 @@ echo `date` " Starting $0 for resource $RESOURCE"
ALLOWHTTPRESPONSES=$3
XFROMAPPID="AAI-TOOLS"
-XTRANSID=`uuidgen`
+XTRANSID="someUUID"
-userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
-if [ "${userid}" != "aaiadmin" ]; then
- echo "You must be aaiadmin to run $0. The id used $userid."
- exit 1
-fi
-PROJECT_HOME=/opt/app/aai-traversal
+: ${PROJECT_HOME:=/opt/app/aai-traversal}
prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
log_dir=$PROJECT_HOME/logs/misc
today=$(date +\%Y-\%m-\%d)
@@ -130,62 +125,69 @@ fi
fname=$JSONFILE
if [ -f /tmp/$(basename $JSONFILE) ]; then
- fname=/tmp/$(basename $JSONFILE)
+ fname=/tmp/$(basename $JSONFILE)
elif [ ! -f $JSONFILE ]; then
- echo "The file $JSONFILE does not exist"
- exit -1
+ 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 "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 -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" -ge 200 && $result -lt 300 ]]
- then
- echo "PUT result is OK, $result"
- else
- if [ -z $ALLOWHTTPRESPONSES ]; then
- echo "PUT request failed, response code was $result"
- RC=$result
- else
- contains $ALLOWHTTPRESPONSES $result
- if [ $? -ne 0 ]
- then
- echo "PUT request failed, unexpected response code was $result"
- RC=$result
- else
- echo "PUT result is expected, $result"
- fi
- fi
- fi
- ;;
- *)
- echo "PUT request failed, response was $result"
- RC=-1
- ;;
-
+ 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 "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 -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
+ # Match one or more digits optionally followed by another character
+ *[0-9]*)
+ if [ "$result" -ge 200 ] && [ "$result" -lt 300 ]; then
+ echo "PUT result is OK, $result"
+ else
+ if [ -z "$ALLOWHTTPRESPONSES" ]; then
+ echo "PUT request failed, response code was $result"
+ RC=$result
+ else
+ # Function to check if a string is in a list of strings
+ contains() {
+ for item in $1; do
+ if [ "$item" = "$2" ]; then
+ return 0
+ fi
+ done
+ return 1
+ }
+ contains "$ALLOWHTTPRESPONSES" "$result"
+ if [ $? -ne 0 ]; then
+ echo "PUT request failed, unexpected response code was $result"
+ RC=$result
+ else
+ echo "PUT result is expected, $result"
+ fi
+ fi
+ fi
+ ;;
+ *)
+ echo "PUT request failed, response was $result"
+ RC=-1
+ ;;
esac
- else
+ else
echo "FAILED to send request to $RESTURL"
RC=-1
- fi
- fi
+ fi
+ fi
else
- echo "usage: $0 resource file [expected-failure-codes]"
- RC=-1
+ echo "usage: $0 resource file [expected-failure-codes]"
+ RC=-1
fi
echo `date` " Done $0, returning $RC"
-exit $RC \ No newline at end of file
+exit $RC
diff --git a/pom.xml b/pom.xml
index cbe9459..4b399eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
</parent>
<groupId>org.onap.aai.traversal</groupId>
<artifactId>traversal</artifactId>
- <version>1.14.3-SNAPSHOT</version>
+ <version>1.14.4-SNAPSHOT</version>
<name>aai-traversal</name>
<packaging>pom</packaging>
<modules>
diff --git a/version.properties b/version.properties
index a9c3f22..82f9610 100644
--- a/version.properties
+++ b/version.properties
@@ -5,7 +5,7 @@
major_version=1
minor_version=14
-patch_version=3
+patch_version=4
base_version=${major_version}.${minor_version}.${patch_version}