#!/bin/sh

#Définir ici l'emplacement de l'exécutable java
export JAVA_BIN=/usr/local/j2sdk/bin/java
export CLASSPATH=$CLASSPATH:classes:lib/activation.jar:lib/antlr-2.7.6.jar:lib/c3p0-0.9.1.jar:lib/commons-collections-3.1.jar:lib/commons-compress-1.1.jar:lib/dom4j-1.6.1.jar:lib/hibernate-jpa-2.0-api-1.0.0.Final.jar:lib/hibernate3.jar:lib/javassist-3.12.0.GA.jar:lib/jdom.jar:lib/jta-1.1.jar:lib/mail.jar:lib/netcdf-4.0.jar:lib/postgresql-8.4-702.jdbc3.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-simple-1.6.1.jar

#Lit stdin (cas de la méthode post)
if [ "$REQUEST_METHOD" = "POST" ]; then
    read QUERY_STRING
fi
export FICHIER_TEMP=`date +%m%d%Y_%H%M%S_%N`.tmp
echo $QUERY_STRING > $FICHIER_TEMP &

$JAVA_BIN \
    -Dcgi.content_type=$CONTENT_TYPE \
    -Dcgi.content_length=$CONTENT_LENGTH \
    -Dcgi.request_method=$REQUEST_METHOD \
    -Dcgi.query_file=$FICHIER_TEMP \
    -Dcgi.server_name=$SERVER_NAME \
    -Dcgi.server_port=$SERVER_PORT \
    -Dcgi.script_name=$SCRIPT_NAME \
    -Dcgi.document_root=$DOCUMENT_ROOT \
    -Dcgi.script_filename=$SCRIPT_FILENAME \
    -Dcgi.path_info=$PATH_INFO \
  extraction.principal.Principal &
