-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpopulateDb
executable file
·60 lines (49 loc) · 1.77 KB
/
populateDb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
host="${1:-localhost}"
port="${2:-9090}"
contentRoot="${3:-/home/*/QNAP/Public/Freecom400GB/jukebox/playlist}"
resources="http://$host:$port/jee6webapp/resources"
content='Content-Type: application/json'
accept='Accept: application/json'
for i in 0 1 2 3 4 5 6 7 8 9
do
curl -X POST -H "$content" -H "$accept" --data-binary "{\"name\":\"user$i\",\"password\":\"password$i\",\"realName\":\"User $i\",\"comments\":\"No comment\"}" $resources/appuser
echo ""
done
curl -i -H "$accept" -X GET $resources/appuser
echo ""
while read a b c d e f g h
do
if [ -n "$h" ]
then
curl -X POST -H "$content" -H "$accept" --data-binary "{\"name\":\"$h\"}" $resources/artist
echo ""
fi
done < <(ls -l $contentRoot)
curl -i -H "$accept" -X GET $resources/artist
echo ""
while read a b c d e f g h
do
if [ -n "$h" ]
then
curl -X POST -H "$content" -H "$accept" --data-binary "{\"name\":\"$h\"}" $resources/album
echo ""
fi
done < <(ls -l $contentRoot/*)
curl -i -H "$accept" -X GET $resources/album
echo ""
while read a b c d e f g h
do
if [ -n "$h" ]
then
curl -X POST -H "$content" -H "$accept" --data-binary "{\"name\":\"$h\"}" $resources/track
echo ""
fi
done < <(ls -l $contentRoot/*/*)
curl -i -H "$accept" -X GET $resources/track
echo ""
exit 0
# examples . . .
curl -X GET -H "Accept: application/json" http://localhost:9090/jee6webapp/resources/artist
curl -X POST --data-binary "{\"name\":\"XXXXX\",\"url\":\"http://doitto.me.uk\",\"duration\":\"210\"}" -H "Content-Type: application/json" -H "Accept: application/json" http://localhost:9090/jee6webapp/resources/track
curl -X PUT --data-binary "{\"name\":\"XXZXX\",\"url\":\"YYYYY\",\"duration\":\"210\"}" -H "Content-Type: application/json" -H "Accept: application/json" http://localhost:9090/jee6webapp/resources/track/1