@ECHO OFF

REM  Batch file for deploying web components to a running Glassfish instance
REM  
REM  ABS_WEBSERVERHOME   			Home folder of web server, for example D:\01\webserver\
REM  ABS_WEBSERVERPORT   			Admin port of web server, for example 50134     
REM  ABS_WEBSERVERSERVICENAME   	Windows service name of the Glassfish service, for example ABSS01_WebSrv   

SET PATH=%PATH%;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
SET ABS_WEBSERVERHOME=[ABS_WEBSERVERHOME]
SET ABS_WEBSERVERPORT=5[ABS_WEBSERVERSLOT][DEPLOY]
SET ABS_WEBSERVERSERVICENAME=[ABS_WEBSERVERSERVICENAME]
SET ABS_Deploy_absgenericwebservice=N
SET ABS_Deploy_absws4mobileapps=N
SET ABS_Deploy_absrestservices=N
SET ABS_Deploy_absmobilerestservices=N

REM Automaticly update with war file and web.xml from customSkins folder -- activate only if needed -- 
REM call %ABS_WEBSERVERHOME%custom\deploy\extract_war_file.bat %ABS_WEBSERVERHOME% %WEBCOMPONENT%
REM for copy web.xml from CustomSkins folder -- activate only when needed --
REM copy /Y %ABS_WEBSERVERHOME%deploy\CustomSkin\web_xml\%WEBCOMPONENT%\web.xml %ABS_DEPLOYHOME%\WEB-INF\web.xml

REM First ask for cleaning up the already deployed web components. This is usefull when Glassfish gets in
REM an unrecoverable state
SET CHOOSE=N
SET /P CHOOSE=Do you want to clean up Tomcat and the deployed web components? ( Type Y for Yes )
IF /I NOT %CHOOSE%==Y GOTO DEPLOYWEBCOMPONENTS
:CLEANUPWEBCOMPONENTS
call %ABS_WEBSERVERHOME%custom\deploy\cleanup_webcomponents.bat %ABS_WEBSERVERHOME% %ABS_WEBSERVERSERVICENAME% %ABS_WEBSERVERPORT%

REM Start deploying the web components

REM For each component, the following variables can be set
REM  WEBCOMPONENT    Name of the to be deployed web component, should match the dedicated deployment folder name 
REM  CONTEXT PATH    Context path of the web component, used for accessing the web component, typically the name 
REM  VIRTUALSERVER   Virtual server to deploy to, default value is server
REM  LIB             For linking jar files not part of the war, typically used for customised skin.jars

:DEPLOYWEBCOMPONENTS

:Deploy_absgenericwebservice
If /I not %ABS_Deploy_absgenericwebservice%==Y GOTO Deploy_absws4mobileapps
REM -------------------------------------------------------
REM Generic Web Service         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absgenericwebservice
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=5[ABS_WEBSERVERSLOT]42
SET SNMP=5.1.0
ECHO -------------------------------------------------------
ECHO Deploy %WEBCOMPONENT%
ECHO   - Context path:   %CONTEXTPATH%
ECHO   - UDP SNMP Port:  %UDPPORT%
ECHO Start deploying...
PAUSE
call %ABS_WEBSERVERHOME%custom\deploy\deploy_webcomponent.bat %ABS_WEBSERVERHOME% %ABS_WEBSERVERPORT% %WEBCOMPONENT% %UDPPORT%
call %ABS_WEBSERVERHOME%custom\deploy\snmpwalk.bat %ABS_WEBSERVERHOME% %UDPPORT% %SNMP% %WEBCOMPONENT%
PAUSE

:Deploy_absws4mobileapps
If /I not %ABS_Deploy_absws4mobileapps%==Y GOTO Deploy_absrestservices
REM -------------------------------------------------------
REM Mobile Web         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absws4mobileapps
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=5[ABS_WEBSERVERSLOT]44
SET SNMP=7.1.0
ECHO -------------------------------------------------------
ECHO Deploy %WEBCOMPONENT%
ECHO   - Context path:   %CONTEXTPATH%
ECHO   - UDP SNMP Port:  %UDPPORT%
ECHO Start deploying...
PAUSE
copy /Y %ABS_WEBSERVERHOME%deploy\CustomSkin\web_xml\%WEBCOMPONENT%\web.xml %ABS_WEBSERVERHOME%deploy\%WEBCOMPONENT%\WEB-INF\web.xml
call %ABS_WEBSERVERHOME%custom\deploy\deploy_webcomponent.bat %ABS_WEBSERVERHOME% %ABS_WEBSERVERPORT% %WEBCOMPONENT% %UDPPORT%
call %ABS_WEBSERVERHOME%custom\deploy\snmpwalk.bat %ABS_WEBSERVERHOME% %UDPPORT% %SNMP% %WEBCOMPONENT%
PAUSE

:Deploy_absrestservices
If /I not %ABS_Deploy_absrestservices%==Y GOTO Deploy_absmobilerestservices
REM -------------------------------------------------------
REM ABS Rest Services     
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absrestservices
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=5[ABS_WEBSERVERSLOT]46
SET SNMP=10.1.0
ECHO -------------------------------------------------------
ECHO Deploy %WEBCOMPONENT%
ECHO   - Context path:   %CONTEXTPATH%
ECHO   - UDP SNMP Port:  %UDPPORT%
ECHO Start deploying...
PAUSE
copy /Y %ABS_WEBSERVERHOME%deploy\CustomSkin\web_xml\%WEBCOMPONENT%\web.xml %ABS_WEBSERVERHOME%deploy\%WEBCOMPONENT%\WEB-INF\web.xml
call %ABS_WEBSERVERHOME%custom\deploy\deploy_webcomponent.bat %ABS_WEBSERVERHOME% %ABS_WEBSERVERPORT% %WEBCOMPONENT% %UDPPORT%
call %ABS_WEBSERVERHOME%custom\deploy\snmpwalk.bat %ABS_WEBSERVERHOME% %UDPPORT% %SNMP% %WEBCOMPONENT%
PAUSE

:Deploy_absmobilerestservices
If /I not %ABS_Deploy_absmobilerestservices%==Y GOTO GOTO End
REM -------------------------------------------------------
REM ABS Mobile Rest Services     
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absmobilerestservices
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=5[ABS_WEBSERVERSLOT]54
SET SNMP=11.1.0
ECHO -------------------------------------------------------
ECHO Deploy %WEBCOMPONENT%
ECHO   - Context path:   %CONTEXTPATH%
ECHO   - UDP SNMP Port:  %UDPPORT%
ECHO Start deploying...
PAUSE
copy /Y %ABS_WEBSERVERHOME%deploy\CustomSkin\web_xml\%WEBCOMPONENT%\web.xml %ABS_WEBSERVERHOME%deploy\%WEBCOMPONENT%\WEB-INF\web.xml
call %ABS_WEBSERVERHOME%custom\deploy\deploy_webcomponent.bat %ABS_WEBSERVERHOME% %ABS_WEBSERVERPORT% %WEBCOMPONENT% %UDPPORT%
call %ABS_WEBSERVERHOME%custom\deploy\snmpwalk.bat %ABS_WEBSERVERHOME% %UDPPORT% %SNMP% %WEBCOMPONENT%
PAUSE

:End
