From b19cc489366cdde4496a0ff78f33eb8737e46d67 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Sun, 19 Jun 2011 16:40:31 +0200 Subject: [PATCH] Tidy not mandatory for example REST scripts. * Fixed doc too. FEA: ItEr74S04BugFixing --- .../howto-develop-a-use-case-in-navalplan.rst | 6 +++--- scripts/rest-clients/README | 2 +- scripts/rest-clients/export-resources-hours.sh | 10 ++++++++-- scripts/rest-clients/export.sh | 10 ++++++++-- scripts/rest-clients/import.sh | 10 ++++++++-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/doc/src/technical/howto-develop-a-use-case-in-navalplan.rst b/doc/src/technical/howto-develop-a-use-case-in-navalplan.rst index 9af412775..b48a4c835 100644 --- a/doc/src/technical/howto-develop-a-use-case-in-navalplan.rst +++ b/doc/src/technical/howto-develop-a-use-case-in-navalplan.rst @@ -2387,9 +2387,9 @@ created in project repository inside ``scripts/rest-clients`` directory. .. NOTE:: - Currently these scripts depends on Tidy to be installed in your - system. You could install them in a Debian based distribution with the - following command as root:: + Currently these scripts recommends Tidy to be installed in your system + for a better output. You could install them in a Debian based distribution + with the following command as root:: apt-get install tidy diff --git a/scripts/rest-clients/README b/scripts/rest-clients/README index e64286856..d5128c205 100644 --- a/scripts/rest-clients/README +++ b/scripts/rest-clients/README @@ -1,4 +1,4 @@ -+ Check you have "tidy" available from the command line. ++ It's recommended to have "tidy" available in your system. + chmod u+x *.sh diff --git a/scripts/rest-clients/export-resources-hours.sh b/scripts/rest-clients/export-resources-hours.sh index 1ce0932be..cf34fd7cc 100755 --- a/scripts/rest-clients/export-resources-hours.sh +++ b/scripts/rest-clients/export-resources-hours.sh @@ -61,5 +61,11 @@ else serviceURIWithParams="$baseServiceURL/resourceshours/$resourceCode/$startDate/$endDate/" fi -curl -sv -X GET $certificate --header "Authorization: Basic $authorization" \ - $serviceURIWithParams | tidy -xml -i -q -utf8 +result=`curl -sv -X GET $certificate --header "Authorization: Basic $authorization" \ + $serviceURIWithParams` + +if hash tidy &> /dev/null; then + echo $result | tidy -xml -i -q -utf8 +else + echo $result +fi diff --git a/scripts/rest-clients/export.sh b/scripts/rest-clients/export.sh index 7b433c835..775b6be74 100755 --- a/scripts/rest-clients/export.sh +++ b/scripts/rest-clients/export.sh @@ -20,5 +20,11 @@ fi authorization=`echo -n "$loginName:$password" | base64` -curl -sv -X GET $certificate --header "Authorization: Basic $authorization" \ - $baseServiceURL/$1 | tidy -xml -i -q -utf8 +result=`curl -sv -X GET $certificate --header "Authorization: Basic $authorization" \ + $baseServiceURL/$1` + +if hash tidy &> /dev/null; then + echo $result | tidy -xml -i -q -utf8 +else + echo $result +fi diff --git a/scripts/rest-clients/import.sh b/scripts/rest-clients/import.sh index e8facdf4a..355d627d0 100644 --- a/scripts/rest-clients/import.sh +++ b/scripts/rest-clients/import.sh @@ -27,7 +27,13 @@ fi authorization=`echo -n "$loginName:$password" | base64` -curl -sv -X POST $certificate -d @$file \ +result=`curl -sv -X POST $certificate -d @$file \ --header "Content-type: application/xml" \ --header "Authorization: Basic $authorization" \ - $baseServiceURL/$1 | tidy -xml -i -q -utf8 + $baseServiceURL/$1` + +if hash tidy &> /dev/null; then + echo $result | tidy -xml -i -q -utf8 +else + echo $result +fi