Skip to content

Commit 48636f6

Browse files
author
jmorton
committed
Fix-up publish.sh shell script, which was broken after some refactors to the property parsing in Java
1 parent 8c6c093 commit 48636f6

File tree

5 files changed

+63
-15
lines changed

5 files changed

+63
-15
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
target/
33
dependency-reduced-pom.xml
44
tableau.iml
5+
tableau-sdk-wrapper*.zip
6+
logs/
7+
tableau-sdk-wrapper-*/
8+
tmp/
9+
lib/
10+
DataExtract.log

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ BIN_DIR = bin
1010
DOCKER_DIR = docker
1111
DOCKER_REPOSITORY = jlmorton
1212

13-
all: mkdir copy_files archive docker
13+
all: compile mkdir copy_files archive docker
14+
15+
compile:
16+
mvn install
1417

1518
mkdir:
1619
${MKDIR_P} ${BUILD_DIR}/bin
@@ -30,6 +33,7 @@ archive:
3033
zip -r ${ARCHIVE} ${BUILD_DIR}
3134

3235
clean:
36+
mvn clean
3337
rm -rf ${BUILD_DIR}
3438
rm -rf ${DOCKER_DIR}/${BUILD_DIR}
3539
rm -f ${ARCHIVE}

bin/publish.sh

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#!/bin/bash
2-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3-
BASE_PATH="$DIR/..";
2+
BASE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."
43
LIB="$BASE_PATH/lib"
54
JARFILE="$LIB/tableau-1.2.jar"
65
SDK_DIR="$LIB/tableausdk-linux64-10300.18.0510.1135"
76
JAVA_SDK_DIR="$SDK_DIR/lib64/tableausdk/Java/"
87

9-
export LD_LIBRARY_PATH="$SDK_DIR/lib64/tableausdk"
8+
export LD_LIBRARY_PATH="$SDK_DIR/lib64/tableausdk:$LD_LIBRARY_PATH"
109

1110
#export http_proxy="http://$PROXY_HOST:$PROXY_PORT"
1211
#export https_proxy="http://$PROXY_HOST:$PROXY_PORT"
1312

14-
usage() { echo "Usage: $0 -e <extract path> -s <site name> -d <datasource name>"; }
15-
while getopts "e:s:d:p:" i; do
13+
set -e
14+
15+
usage() { echo "Usage: $0 -e <extract path> -s <site name> -d <datasource name> -u <url> -p <project name> -n <username> -x <password>"; exit 1; }
16+
while getopts "u:n:x:e:s:d:p:" i; do
1617
case "${i}" in
1718
u) url=${OPTARG};;
1819
n) username=${OPTARG};;
@@ -26,9 +27,39 @@ while getopts "e:s:d:p:" i; do
2627
done
2728
shift $((OPTIND-1))
2829

29-
if [[ -z $extract ]] || [[ -z $site ]] || [[ -z $datasource_name ]] || [[ -z $project_name ]]; then
30-
usage
31-
exit
30+
if [[ -z $extract ]]; then
31+
echo "Error: extract argument expected (-e <extract>)";
32+
usage;
33+
fi
34+
35+
if [[ -z $site ]]; then
36+
echo "Error: site name argument expected (-s <site name>)";
37+
usage;
38+
fi
39+
40+
if [[ -z $datasource_name ]]; then
41+
echo "Error: datasource name argument expected (-d <datasource name>)";
42+
usage;
43+
fi
44+
45+
if [[ -z $url ]]; then
46+
echo "Error: Tableau servre URL argument expected (-u <url>)";
47+
usage;
48+
fi
49+
50+
if [[ -z $project_name ]]; then
51+
echo "Error: Project Name argument expected (-p <project>)";
52+
usage;
53+
fi
54+
55+
if [[ -z $username ]]; then
56+
echo "Error: Username argument expected (-n <username>)";
57+
usage;
58+
fi
59+
60+
if [[ -z $password ]]; then
61+
echo "Error: Password argument expected (-x <password>)";
62+
usage;
3263
fi
3364

34-
java -jar $JARFILE -p -extract $extract -site $site -project $project_name -name $datasource_name
65+
java -jar $JARFILE -p -extract $extract -site $site -project $project_name -datasource $datasource_name -url $url -username $username -password $password

src/main/java/net/jlmorton/tableau/CommandLinePropertySource.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.jlmorton.tableau;
22

33
import org.apache.commons.cli.*;
4+
import org.apache.commons.lang3.StringUtils;
45
import org.apache.logging.log4j.LogManager;
56
import org.apache.logging.log4j.Logger;
67

@@ -28,7 +29,13 @@ public Schema getSchema() {
2829

2930
@Override
3031
public File getCsvFile() {
31-
return new File(commandLine.getOptionValue("file"));
32+
String csvFilePath = commandLine.getOptionValue("file");
33+
34+
if (StringUtils.isBlank(csvFilePath)) {
35+
return null;
36+
}
37+
38+
return new File(csvFilePath);
3239
}
3340

3441
@Override

src/main/java/net/jlmorton/tableau/Main.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public static void main(String... args) throws Exception {
1515
CommandLinePropertySource commandLinePropertySource = new CommandLinePropertySource(args);
1616
Properties properties = commandLinePropertySource.getProperties();
1717

18-
if (properties.isExtract()) {
19-
createExtract(properties);
20-
}
21-
2218
if (properties.isPublish()) {
2319
publish(properties);
2420
}
2521

22+
if (properties.isExtract()) {
23+
createExtract(properties);
24+
}
25+
2626
if (!properties.isExtract() & !properties.isPublish()) {
2727
CommandLinePropertySource.printHelp();
2828
}

0 commit comments

Comments
 (0)