@echo off
REM
REM (c) 1999-2003 Oracle Corp. all rights reserved
REM
REM J2ME SDK Manager. Provides a command line tool to manage J2ME SDK services.
REM

setlocal
call j2me_env.bat
if "%IAS_HOME%" =="" set IAS_HOME=%ORACLE_HOME%
if not %ERRORLEVEL% == 0 goto end
if "%IAS_HOME%" == "" goto end

set ACTION=NOTSET%1
if %ACTION% == NOTSET goto error2
if /i %1 == help goto error2
if /i %1 == -help goto error2
if /i %1 == --help goto error2
if %1 == ? goto error2
if %1 == -? goto error2
if %1 == --? goto error2

if "%PROXY_URL%" == "" goto error
if "%J2ME_SERVER_HOME%" == "" goto error

if /i %1 == -generatestub goto genstubaction
if /i %1 == generatestub goto genstubaction

if /i %1 == -export goto exportaction
if /i %1 == export goto exportaction

if /i %1 == -registerclass goto registerclassaction
if /i %1 == registerclass goto registerclassaction

if /i %1 == -registerwsdl goto registerwsdlaction
if /i %1 == registerwsdl goto registerwsdlaction

if /i %1 == -listservices goto listservicesaction
if /i %1 == listservices goto listservicesaction

if /i %1 == -removeservice goto removeserviceaction
if /i %1 == removeservice goto removeserviceaction

echo Invalid option specified
goto error2

:genstubaction
set SERVICE_NAME=NOTSET%2
if %SERVICE_NAME%==NOTSET goto genstuberror
java -mx50m -classpath "%CLASSPATH%;" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" oracle.wireless.me.server.ServiceManagerStandalone generatestub %2 %3 %4
goto end

:genstuberror
ECHO Usage:
ECHO j2mesdkmgr -generatestub [^<namespace^>.]^<service name^> [^<Output directory^> [^<stub name^>]]
ECHO Examples:
ECHO j2mesdkmgr -generatestub TestWebService
ECHO j2mesdkmgr -generatestub TestWebService c:\temp
ECHO j2mesdkmgr -generatestub TestWebService c:\temp TestServiceStub
goto end


:exportaction
set XMLFILE=NOTSET%2
if %XMLFILE%==NOTSET goto exporterror
rem we hardcode the export literatl here. since the option specified may possibly be prefixed with -
java -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" oracle.wireless.me.server.J2MEProxyMigrationStandalone export %2
goto end

:exporterror
ECHO Usage:
ECHO  j2mesdkmgr -export ^<xml file name^>
goto end

:registerclassaction

set LIB_URL=NOTSET%2
set CLASS_NAME=NOTSET%3
set NAMESPACE=NOTSET%4
if %LIB_URL%==NOTSET goto errorregisterclass
if %CLASS_NAME%==NOTSET goto errorregisterclass

if %NAMESPACE%==NOTSET goto nonamespace1

java -mx50m -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" oracle.wireless.me.server.RegistrationManager -mode class -libUrl %2 -namespace %4 %3

goto end

:nonamespace1

java -mx50m -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%"  oracle.wireless.me.server.RegistrationManager -mode class -libUrl %2 %3

goto end


:errorregisterclass
ECHO Usage:
ECHO j2mesdkmgr -registerclass ^<URL of the Class Library^> ^<Name of the class^> [^<namespace^>]
ECHO Example:
ECHO j2mesdkmgr -registerclass file:C:/iaswv904/wireless/wdk/server/applications/wdk/wdk-web/webservice/lib/testservices.jar oracle.web.TestWebservice
goto end

:registerwsdlaction

set WSDL_NAME=NOTSET%2
set NAMESPACE=NOTSET%3
if %WSDL_NAME%==NOTSET goto errorregisterwsdl

if %NAMESPACE%==NOTSET goto nonamespace2

REM Regular execution
java -mx50m -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" oracle.wireless.me.server.RegistrationManager -mode wsdl -namespace %3 %2

REM Execution through HTTP proxy server
REM java -mx50m -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" -Dhttp.useProxy=true -Dhttp.proxyHost=www-proxy.us.oracle.com -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts=localhost oracle.wireless.me.server.RegistrationManager -mode wsdl -namespace %3 %2

goto end

:nonamespace2
REM Regular execution
java -mx50m -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" oracle.wireless.me.server.RegistrationManager -mode wsdl %2

REM Execution through HTTP proxy server
REM java -mx50m -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" -Dhttp.useProxy=true -Dhttp.proxyHost=www-proxy.us.oracle.com -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts=localhost oracle.wireless.me.server.RegistrationManager -mode wsdl %2

goto end

:errorregisterwsdl
ECHO Usage:
ECHO  j2mesdkmgr -registerwsdl ^<URL of the WSDL^> [^<namespace^>]
ECHO Example:
ECHO j2mesdkmgr -registerwsdl file:C:/iaswv904/wireless/wdk/j2me/sample/PushLite.wsdl
goto end


:listservicesaction
java -mx50m -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" oracle.wireless.me.server.ServiceManagerStandalone listservices
goto end

:removeserviceaction
set WSNAME=NOTSET%2
if %WSNAME%==NOTSET goto error2
java -classpath "%CLASSPATH%" -DJ2ME_SERVER_HOME="%J2ME_SERVER_HOME%" -DPROXY_URL="%PROXY_URL%" -DPROXY_MODE="%PROXY_MODE%" -DPROXY_LOG_DIR="%PROXY_LOG_DIR%" oracle.wireless.me.server.ServiceManagerStandalone removeservice %2
goto end

:error

ECHO ERROR!!! You MUST define ORACLE_HOME, J2ME_SERVER_HOME and PROXY_URL for your IAS Installation to run this script.  Please configure j2me_env.bat .

goto end

:error2
ECHO Usage: j2mesdkmgr ^<action^> [^<argument^>...]
ECHO where ^<action^> and corresponding argument include:
ECHO   -registerclass ^<URL of the Class Library^> ^<Name of the class^> [^<namespace^>]
ECHO       Registers the specified class.
ECHO.
ECHO   -registerwsdl ^<URL of the WSDL^> [^<namespace^>]
ECHO       Registers the web services in the specified WSDL document.
ECHO.
ECHO   -generatestub [^<namespace^>.]^<service name^> [^<Output directory^>[^<stub name^>]]
ECHO       Generates a J2ME client stub.
ECHO.
ECHO   -export ^<xml file name^>
ECHO       Exports all registered web services to an XML file for migration to IASW.
ECHO.
ECHO   -listservices
ECHO       Lists the registered web services.
ECHO.
ECHO   -removeservice [^<namespace^>.]^<service name^>
ECHO       Removes the specified web service.
ECHO.
ECHO   -help ^| -?
ECHO       Print a synopsis of standard options.
:end
endlocal
