@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=[ABS_WEBADMINSLOT]
SET ABS_WEBSERVERSERVICENAME=[ABS_WEBSERVERSERVICENAME]
SET ABS_Deploy_absgenericwebservice=N
SET ABS_Deploy_absuhfmonitor=N
SET ABS_Deploy_webclientcleanroompackinginstructions=N
SET ABS_Deploy_absmobilefirebaseservices=N
SET ABS_Deploy_absws4mobileapps=N
SET ABS_Deploy_webclientresidentialdelivery=N
SET ABS_Deploy_webclientroutereturns=N
SET ABS_Deploy_webclientreplacesmartbarcode=N
SET ABS_Deploy_webclientx=N
SET ABS_Deploy_absrestservices=N
SET ABS_Deploy_absmobilerestservices=N
SET ABS_Deploy_abswebportal=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_absuhfmonitor
REM -------------------------------------------------------
REM Generic Web Service         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absgenericwebservice
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]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_absuhfmonitor
If /I not %ABS_Deploy_absuhfmonitor%==Y GOTO Deploy_absmobilefirebaseservices
REM -------------------------------------------------------
REM UHF Monitor         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absuhfmonitor
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]47
SET SNMP=8.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_webclientcleanroompackinginstructions
If /I not %ABS_Deploy_webclientcleanroompackinginstructions%==Y GOTO Deploy_absmobilefirebaseservices
REM -------------------------------------------------------
REM WebClient CleanroomPacking     
REM ------------------------------------------------------- 
SET WEBCOMPONENT=webclientcleanroompackinginstructions
SET CONTEXTPATH=%WEBCOMPONENT%
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]55
SET SNMP=16.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_absmobilefirebaseservices
If /I not %ABS_Deploy_absmobilefirebaseservices%==Y GOTO Deploy_absws4mobileapps
REM -------------------------------------------------------
REM Mobile Firebase       
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absmobilefirebaseservices
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]52
SET SNMP=12.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_WebClientResidentialDelivery
REM -------------------------------------------------------
REM Mobile Web         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absws4mobileapps
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]44
SET SNMP=7.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_WebClientResidentialDelivery
If /I not %ABS_Deploy_webclientresidentialdelivery%==Y GOTO Deploy_WebClientRouteReturns
REM -------------------------------------------------------
REM Mobile Web         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=webclientresidentialdelivery
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]50
SET SNMP=14.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_WebClientRouteReturns
If /I not %ABS_Deploy_webclientroutereturns%==Y GOTO Deploy_WebClientReplaceSmartBarcode
REM -------------------------------------------------------
REM Mobile Web         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=webclientroutereturns
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]51
SET SNMP=13.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_WebClientReplaceSmartBarcode
If /I not %ABS_Deploy_webclientreplacesmartbarcode%==Y GOTO Deploy_webclientx
REM -------------------------------------------------------
REM Mobile Web         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=webclientreplacesmartbarcode
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]53
SET SNMP=15.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_webclientx
If /I not %ABS_Deploy_webclientx%==Y GOTO Deploy_absrestservices
REM -------------------------------------------------------
REM WebClientX      
REM ------------------------------------------------------- 
SET WEBCOMPONENT=webclientx
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]48
SET SNMP=9.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_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=[ABS_UDP]46
SET SNMP=10.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_absmobilerestservices
If /I not %ABS_Deploy_absmobilerestservices%==Y GOTO Deploy_abswebportal
REM -------------------------------------------------------
REM ABS Mobile Rest Services     
REM ------------------------------------------------------- 
SET WEBCOMPONENT=absmobilerestservices
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]54
SET SNMP=11.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_abswebportal
If /I not %ABS_Deploy_abswebportal%==Y GOTO End
REM -------------------------------------------------------
REM Portal
REM 
REM Use the additional DEFAULT_LOCALE option to control the language of the Portal's log in page. Make sure to have the corresponding resources jar file in the WEB-INF\lib as well         
REM ------------------------------------------------------- 
SET WEBCOMPONENT=abswebportal
SET CONTEXTPATH=%WEBCOMPONENT%
SET UDPPORT=[ABS_UDP]45
SET SNMP=3.1.0
ECHO -------------------------------------------------------
ECHO Deploy %WEBCOMPONENT%
ECHO   - Context path:   %CONTEXTPATH%
ECHO   - UDP SNMP Port:  %UDPPORT%
ECHO Start deploying...
PAUSE
ECHO Deploy custom skins for the %WEBCOMPONENT%
copy /Y %ABS_WEBSERVERHOME%deploy\CustomSkin\images %ABS_WEBSERVERHOME%deploy\%WEBCOMPONENT%\resources\abs\1_0\images
ECHO Deploy custom Language RESOURCES for %WEBCOMPONENT%
copy /Y %ABS_WEBSERVERHOME%deploy\CustomSkin\custome_resources %ABS_WEBSERVERHOME%deploy\%WEBCOMPONENT%\WEB-INF\lib
REM ---------------------------------------------------------
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
