@echo off
more "%~dp0\LICENSE.txt"
@echo off
set /p accept="Accept above End User License Agreement(EULA)? (Y/N) " %=%

call :trim trim_accept %accept%

if "%trim_accept%"=="Y" goto install_sdk
if "%trim_accept%"=="y" goto install_sdk

echo EULA is not accepted, install terminated!!!.

exit /b 1

:install_sdk
cd %~d0%~p0
call eclipse.bat

SET SDK_VERSION=3.9

call :install_jar "%~dp0\lib\archive-xsd.jar" "%~dp0\lib\archive-xsd.pom" || goto ERROR
call :install_jar "%~dp0\lib\xsds.pom" "%~dp0\lib\xsds.pom" || goto ERROR
call :install_jar "%~dp0\lib\java-facade.jar" "%~dp0\lib\java-facade.pom" || goto ERROR
call :install_jar "%~dp0\lib\unit-test-utils.jar" "%~dp0\lib\unit-test-utils.pom" || goto ERROR
call :install_jar  "%~dp0\lib\avaya-aura-collaboration-api-%SDK_VERSION%.jar" "%~dp0\lib\avaya-aura-collaboration-api-%SDK_VERSION%.pom" || goto ERROR
call :install_jar  "%~dp0\lib\avaya-aura-collaboration-sdk.pom" "%~dp0\lib\avaya-aura-collaboration-sdk.pom" || goto ERROR
call :install_jar "%~dp0\lib\zephyrDataUtil.jar" "%~dp0\lib\zephyrDataUtil.pom" || goto ERROR
call :install_jar "%~dp0\lib\avaya-commons-java-pom.pom" "%~dp0\lib\avaya-commons-java-pom.pom" || goto ERROR
call :install_jar "%~dp0\lib\avaya-commons-pom.pom" "%~dp0\lib\avaya-commons-pom.pom" || goto ERROR
call :install_jar "%~dp0\lib\avaya-logging-client.jar" "%~dp0\lib\avaya-logging-client.pom" || goto ERROR
call :install_jar "%~dp0\lib\avaya-commons-io.jar" "%~dp0\lib\avaya-commons-io.pom" || goto ERROR
call :install_jar  "%~dp0\lib\asm-common.jar" "%~dp0\lib\asm-common.pom" || goto ERROR
call :install_jar  "%~dp0\lib\avaya-commons-lang.jar" "%~dp0\lib\avaya-commons-lang.pom" || goto ERROR
call :install_jar  "%~dp0\lib\sdk.pom" "%~dp0\lib\sdk.pom" || goto ERROR
call :install_archetype "%~dp0\lib\service-archetype.jar" "%~dp0\lib\service-archetype.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\smc-api.jar" "%~dp0\lib\smc-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\smc.pom" "%~dp0\lib\smc.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\logging-api.jar" "%~dp0\lib\logging-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\logging.pom" "%~dp0\lib\logging.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\schedConf-api.jar" "%~dp0\lib\schedConf-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\schedConf.pom" "%~dp0\lib\schedConf.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\sms-api.jar" "%~dp0\lib\sms-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\sms.pom" "%~dp0\lib\sms.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\email-api.jar" "%~dp0\lib\email-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\email.pom" "%~dp0\lib\email.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\eventing-api.jar" "%~dp0\lib\eventing-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\eventing.pom" "%~dp0\lib\eventing.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\http-api.jar" "%~dp0\lib\http-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\http.pom" "%~dp0\lib\http.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\ssl_util-api.jar" "%~dp0\lib\ssl_util-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\ssl_util.pom" "%~dp0\lib\ssl_util.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\authorization_helper-api.jar" "%~dp0\lib\authorization_helper-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar"  || goto ERROR
call :install_jar "%~dp0\lib\authorization_helper.pom" "%~dp0\lib\authorization_helper.pom"  || goto ERROR
call :install_jar_javadoc "%~dp0\lib\serviceActivity-api.jar" "%~dp0\lib\serviceActivity-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\serviceActivity.pom" "%~dp0\lib\serviceActivity.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\reliableeventing-api.jar" "%~dp0\lib\reliableeventing-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\reliableeventing.pom" "%~dp0\lib\reliableeventing.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\platformListener-api.jar" "%~dp0\lib\platformListener-api.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\platformListener.pom" "%~dp0\lib\platformListener.pom" || goto ERROR
call :install_jar "%~dp0\lib\archive-xsd.jar" "%~dp0\lib\archive-xsd.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\archive-jaxb.jar" "%~dp0\lib\archive-jaxb.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\zephyrDataApiFactory.jar" "%~dp0\lib\zephyrDataApiFactory.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\zephyrDM.jar" "%~dp0\lib\zephyrDM.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\zephyrDataAPI.jar" "%~dp0\lib\zephyrDataAPI.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\ceSystemStatus.jar" "%~dp0\lib\ceSystemStatus.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\zephyrEncryptDecrypt.jar" "%~dp0\lib\zephyrEncryptDecrypt.pom" || goto ERROR
call :install_jar "%~dp0\lib\zephyrCommon.pom" "%~dp0\lib\zephyrCommon.pom" || goto ERROR
call :install_jar "%~dp0\lib\zephyrDAO.pom" "%~dp0\lib\zephyrDAO.pom" || goto ERROR
call :install_jar "%~dp0\lib\sample_services.pom" "%~dp0\lib\sample_services.pom" || goto ERROR
call :install_jar "%~dp0\lib\collaborationBus.pom" "%~dp0\lib\collaborationBus.pom" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\collaborationBusAPI.jar" "%~dp0\lib\collaborationBusAPI.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar_javadoc "%~dp0\lib\collaborationBusFactory.jar" "%~dp0\lib\collaborationBusFactory.pom" "%~dp0\javadoc\avaya-aura-collaboration-javadoc-%SDK_VERSION%.jar" || goto ERROR
call :install_jar "%~dp0\lib\platform.pom" "%~dp0\lib\platform.pom" || goto ERROR
call :install_jar "%~dp0\lib\main.pom" "%~dp0\lib\main.pom" || goto ERROR
call :install_jar "%~dp0\lib\api.pom" "%~dp0\lib\api.pom" || goto ERROR
call :install_jar "%~dp0\lib\schemas.pom" "%~dp0\lib\schemas.pom" || goto ERROR
 
call mvn archetype:crawl -Dcatalog="${settings.localRepository}/../archetype-catalog.xml" || goto ERROR

@echo off

chcp 1252 >NUL
set /p accept="Avaya Breeze(R) platform SDK installation succesful.Enter any key to close the prompt."

exit /b



 
:LICENSE_REJECTEED


:install_jar
        call mvn install:install-file ^
                -Dfile=%1 ^
                -DpomFile=%2
        if ERRORLEVEL 1 exit /b 1
exit /b
 
:install_jar_javadoc
        call mvn install:install-file ^
                -Dfile=%1 ^
                -DpomFile=%2 ^
                -Djavadoc=%3
        if ERRORLEVEL 1 exit /b 1
exit /b
 
:install_archetype
        call mvn install:install-file ^
                -Dfile=%1 ^
                -DpomFile=%2 ^
                -Dpackaging=jar
        if ERRORLEVEL 1 exit /b 1
exit /b

:trim
	SetLocal EnableDelayedExpansion
	set Params=%*
	for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b
exit /b
 
:ERROR

@echo off
set /p accept="Avaya Breeze(R) platform SDK installation failed.Enter any key to close the prompt."

exit /b
