ItEr40S20CUImportacionRecursosProductivosItEr39S23: "scripts/rest-clients" folder has been created with initial scripts for REST clients.
The new foler includes a README file (please, update it when adding new scripts), common scripts (base64.sh and rest-common-env.sh), two scripts (post-criterions-types.sh and get-criterion-types.sh) for importing/exporting criterion types, and a sample file (criterion-types-sample.xml) with criterion types to be imported.
This commit is contained in:
parent
553439893e
commit
e4d9fa0e01
6 changed files with 200 additions and 0 deletions
28
scripts/rest-clients/README
Normal file
28
scripts/rest-clients/README
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
+ Check you have "tidy" available from the command line.
|
||||
|
||||
+ Check you have "/usr/bin/ruby".
|
||||
|
||||
+ chmod u+x *.sh
|
||||
|
||||
+ When working with the local application:
|
||||
|
||||
* [Optional] For clarity: remove "navaldev" database + reload Jetty.
|
||||
|
||||
* Import criterion types:
|
||||
|
||||
- post-criterions-types.sh criterion-types-sample.xml
|
||||
(authenticate with wswriter/wswriter)
|
||||
|
||||
- Check the returned errors are consistent with the comments in
|
||||
criterion-types-sample.xml.
|
||||
|
||||
* Export criterion types:
|
||||
|
||||
- get-criterion-types.sh (authenticate with wsreader/wsreader)
|
||||
|
||||
+ When working with the online demo:
|
||||
|
||||
* post-criterions-types.sh --prod criterion-types-sample.xml
|
||||
(authenticate with wswriter/wswriter)
|
||||
|
||||
* get-criterion-types.sh --prod (authenticate with wsreader/wsreader)
|
||||
4
scripts/rest-clients/base64.sh
Executable file
4
scripts/rest-clients/base64.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/ruby
|
||||
|
||||
require 'base64'
|
||||
puts Base64.encode64("#{ARGV[0]}");
|
||||
106
scripts/rest-clients/criterion-types-sample.xml
Normal file
106
scripts/rest-clients/criterion-types-sample.xml
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
<criterion-type-list xmlns="http://rest.ws.navalplanner.org">
|
||||
|
||||
<!-- Several errors: see comments -->
|
||||
<criterion-type name="ct-1" description="ct-1 desc"
|
||||
allow-hierarchy="false"
|
||||
allow-simultaneous-criterions-per-resource="true" enabled="true"
|
||||
resource="RESOURCE">
|
||||
|
||||
<criterion-list>
|
||||
<!-- Missing criterion name -->
|
||||
<criterion active="true"/>
|
||||
<criterion name="c2" active="true">
|
||||
<!-- Criterion hierarchy is not allowed -->
|
||||
<children>
|
||||
<criterion name="c2-1" active="true">
|
||||
<children>
|
||||
<criterion name="c2-1-1" active="false"/>
|
||||
<criterion name="c2-1-2" active="true"/>
|
||||
</children>
|
||||
</criterion>
|
||||
<!-- Repeated criterion name -->
|
||||
<criterion name="c2-1" active="true"/>
|
||||
</children>
|
||||
</criterion>
|
||||
</criterion-list>
|
||||
</criterion-type>
|
||||
|
||||
<!-- Missing criterion type name -->
|
||||
<criterion-type description="ct-2 desc" allow-hierarchy="true"
|
||||
allow-simultaneous-criterions-per-resource="true" enabled="true"
|
||||
resource="RESOURCE">
|
||||
<criterion-list>
|
||||
<criterion name="c1" active="true"/>
|
||||
<criterion name="c2" active="true"/>
|
||||
</criterion-list>
|
||||
</criterion-type>
|
||||
|
||||
<!-- OK -->
|
||||
<criterion-type name="ct-4" description="ct-4 desc" allow-hierarchy="true"
|
||||
allow-simultaneous-criterions-per-resource="true" enabled="true"
|
||||
resource="RESOURCE">
|
||||
|
||||
<criterion-list>
|
||||
<criterion name="c1" active="true"/>
|
||||
<criterion name="c2" active="true">
|
||||
<children>
|
||||
<criterion name="c2-1" active="true">
|
||||
<children>
|
||||
<criterion name="c2-1-1" active="false"/>
|
||||
<criterion name="c2-1-2" active="true"/>
|
||||
</children>
|
||||
</criterion>
|
||||
<criterion name="c2-2" active="true"/>
|
||||
</children>
|
||||
</criterion>
|
||||
</criterion-list>
|
||||
</criterion-type>
|
||||
|
||||
<!-- Repeated criterion type name (see above) -->
|
||||
<criterion-type name="ct-4" description="ct-4 desc" allow-hierarchy="false"
|
||||
allow-simultaneous-criterions-per-resource="false" enabled="false"
|
||||
resource="WORKER"/>
|
||||
|
||||
<!-- Repeated criterion type name (probably a criterion type with this name
|
||||
already exists in the database) -->
|
||||
<criterion-type name="TRAINING" description="ct-4 desc"
|
||||
allow-hierarchy="false" allow-simultaneous-criterions-per-resource="false" enabled="false" resource="WORKER"/>
|
||||
|
||||
<!-- A non-active criterion has an active subcriterion -->
|
||||
<criterion-type name="ct-5" description="ct-5 desc" allow-hierarchy="true"
|
||||
allow-simultaneous-criterions-per-resource="true" enabled="true"
|
||||
resource="RESOURCE">
|
||||
|
||||
<criterion-list>
|
||||
<criterion name="c1" active="true"/>
|
||||
<criterion name="c2" active="false">
|
||||
<children>
|
||||
<criterion name="c2-1" active="false"/>
|
||||
<criterion name="c2-2" active="false">
|
||||
<children>
|
||||
<criterion name="c2-2-1" active="true"/>
|
||||
</children>
|
||||
</criterion>
|
||||
</children>
|
||||
</criterion>
|
||||
</criterion-list>
|
||||
</criterion-type>
|
||||
|
||||
<!-- OK -->
|
||||
<criterion-type name="ct-6" description="ct-6 desc"
|
||||
allow-hierarchy="false" allow-simultaneous-criterions-per-resource="false" enabled="false" resource="WORKER"/>
|
||||
|
||||
<!-- Resource type does not allow enabled criteria -->
|
||||
<criterion-type name="ct-7" description="ct-5 desc" allow-hierarchy="true"
|
||||
allow-simultaneous-criterions-per-resource="true" enabled="false"
|
||||
resource="RESOURCE">
|
||||
|
||||
<criterion-list>
|
||||
<criterion name="c1" active="true"/>
|
||||
<criterion name="c2" active="false"/>
|
||||
</criterion-list>
|
||||
</criterion-type>
|
||||
|
||||
</criterion-type-list>
|
||||
21
scripts/rest-clients/get-criterion-types.sh
Executable file
21
scripts/rest-clients/get-criterion-types.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./rest-common-env.sh
|
||||
|
||||
printf "Login name: "
|
||||
read loginName
|
||||
printf "Password: "
|
||||
read password
|
||||
|
||||
if [ "$1" = "--prod" ]; then
|
||||
baseServiceURL=$PRODUCTION_BASE_SERVICE_URL
|
||||
certificate=$PRODUCTION_CERTIFICATE
|
||||
else
|
||||
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
|
||||
certificate=$DEVELOPMENT_CERTIFICATE
|
||||
fi
|
||||
|
||||
authorization=`./base64.sh $loginName:$password`
|
||||
|
||||
curl -sv -X GET $certificate --header "Authorization: Basic $authorization" \
|
||||
$baseServiceURL/criteriontypes | tidy -xml -i -q -utf8
|
||||
33
scripts/rest-clients/post-criterions-types.sh
Executable file
33
scripts/rest-clients/post-criterions-types.sh
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./rest-common-env.sh
|
||||
|
||||
printf "Login name: "
|
||||
read loginName
|
||||
printf "Password: "
|
||||
read password
|
||||
|
||||
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
|
||||
certificate=$DEVELOPMENT_CERTIFICATE
|
||||
|
||||
for i in "$@"
|
||||
do
|
||||
if [ "$i" = "--prod" ]; then
|
||||
baseServiceURL=$PRODUCTION_BASE_SERVICE_URL
|
||||
certificate=$PRODUCTION_CERTIFICATE
|
||||
else
|
||||
file=$i
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$file" = "" ]; then
|
||||
printf "Missing file\n" 1>&2
|
||||
exit -1
|
||||
fi
|
||||
|
||||
authorization=`./base64.sh $loginName:$password`
|
||||
|
||||
curl -sv -X POST $certificate -d @$file \
|
||||
--header "Content-type: application/xml" \
|
||||
--header "Authorization: Basic $authorization" \
|
||||
$baseServiceURL/criteriontypes | tidy -xml -i -q -utf8
|
||||
8
scripts/rest-clients/rest-common-env.sh
Executable file
8
scripts/rest-clients/rest-common-env.sh
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
DEVELOPMENT_BASE_SERVICE_URL=http://localhost:8080/navalplanner-webapp/ws/rest
|
||||
PRODUCTION_BASE_SERVICE_URL=https://naval.igalia.com/navalplanner-webapp/ws/rest
|
||||
|
||||
DEVELOPMENT_CERTIFICATE=""
|
||||
# FIXME: Until we have a valid production certificate, accept any
|
||||
# server-provided certificate.
|
||||
PRODUCTION_CERTIFICATE=-k
|
||||
#PRODUCTION_CERTIFICATE=--cacert igalia-certificate.pem
|
||||
Loading…
Add table
Reference in a new issue