@echo off

@REM ==============================
@REM  Check environment properties
@REM ==============================

set WLS_HOME=wlserver_10.0

if not defined BEA_HOME goto nobeahome
if not exist %BEA_HOME%\. (echo Error : BEA_HOME [%BEA_HOME%] does not point to a valid directory.) & (goto end) 

if not defined JAVA_HOME goto nojavahome
if not exist %JAVA_HOME%\. (echo Error : JAVA_HOME [%JAVA_HOME%] does not point to a valid directory.) & (goto end) 

if not defined WLI_UTIL_HOME goto nowliutilhome
if not exist %WLI_UTIL_HOME%\. (echo Error : WLI_UTIL_HOME [%WLI_UTIL_HOME%] does not point to a valid directory.) & (goto end)

if not defined JYTHON_HOME (set JYTHON_HOME=%BEA_HOME%\%WLS_HOME%\common\lib) & (@echo JYTHON_HOME was set to the default location %JYTHON_HOME%)
if not exist %JYTHON_HOME%\. ( echo Error : JYTHON_HOME [%JYTHON_HOME%] does not point to a valid directory.) & (goto end) 

if not defined DOMAIN_HOME (set DOMAIN_HOME=%BEA_HOME%\user_projects) & ( @echo DOMAIN_HOME was set to the default location %DOMAIN_HOME%)
if not exist %DOMAIN_HOME%\. (echo Error : DOMAIN_HOME [%DOMAIN_HOME%] does not point to a valid directory.) & (goto end) 

@REM ==========================
@REM   Add ant to PATH
@REM ==========================

set PATH=%BEA_HOME%\%WLS_HOME%\server\bin;%BEA_HOME%\%WLS_HOME%\common\bin;%PATH%

@REM ==========================
@REM    Create env.properties
@REM ==========================

cd ..
set CLIENT_HOME=%cd%
if defined CLIENT_HOME set CLIENT_HOME=%CLIENT_HOME:\=\\%
cd scripts
if not defined CLIENT_HOME set CLIENT_HOME=..
if exist env.properties DEL env.properties

echo.>env.properties
echo tools.dir=%WLI_UTIL_HOME:\=\\%>>env.properties
echo bea.home=%BEA_HOME:\=\\%>>env.properties
echo jython.home=%JYTHON_HOME:\=\\%>>env.properties
echo jdk.home=%JAVA_HOME:\=\\%>>env.properties
echo domain.base=%DOMAIN_HOME:\=\\%>>env.properties
echo weblogic.name=%WLS_HOME:\=\\%>>env.properties

echo .>>env.properties
echo CLIENT_HOME=%CLIENT_HOME%>>env.properties
echo input.document.store=%CLIENT_HOME%\\client\\resources\\input_data>>env.properties
echo selector.property.file=%CLIENT_HOME%\\client\\resources\\query\\%SELECTOR_PROPERTY_FILE%>>env.properties
echo mode=%MODE%>>env.properties
echo server.url=%SERVER_URL%>>env.properties
echo user=%WLS_USER%>>env.properties
echo password=%WLS_PASSWORD%>>env.properties

echo Environment Set.

goto end


@REM ==========================
@REM   Error Messages
@REM ==========================

:nobeahome
@echo ---------- 
@echo Error : BEA_HOME was not set. Please set this variable to the root directory of the BEA Platform installation.
goto end

:nowliutilhome
@echo ---------- 
@echo Please download and unzip the WLI common utilities. Then set this variable to the root directory (wli_util).
goto end

:nojavahome
@echo ---------- 
@echo Error : JAVA_HOME was not set. Please set this variable to the root directory of a JDK installation.
goto end

:end
set classpath=

