NBR_PARALLEL_CREATIONS=${1:-5}

function create_document {
    curl -su Administrator:Administrator -XPOST \
-H 'Content-Type:application/json' \
-H 'accept: text/plain,application/json' \
http://localhost:8080/nuxeo/api/v1/repo/default/path/default-domain/UserWorkspaces/Administrator \
-d '{ "entity-type":"document", "name":"File'"$1"'","type":"File", "properties": { "dc:title":"File'"$1"'"} }' \
>/dev/null 2>&1 &
}

declare -i nbr
nbr=$NBR_PARALLEL_CREATIONS
for ((i=0; i<$nbr; i++))
do
    echo "* Creating document #$i..."
    create_document $i
done
echo "* Done."

exit 0
