Fix HTTPS configuration on PDP-A
[policy/apex-pdp.git] / packages / apex-pdp-package-full / src / main / package / scripts / apexApps.bat
1 :: ============LICENSE_START=======================================================
2 ::  Copyright (C) 2016-2018 Ericsson. All rights reserved.
3 :: ================================================================================
4 :: Licensed under the Apache License, Version 2.0 (the "License");
5 :: you may not use this file except in compliance with the License.
6 :: You may obtain a copy of the License at
7 :: 
8 ::      http://www.apache.org/licenses/LICENSE-2.0
9 :: 
10 :: Unless required by applicable law or agreed to in writing, software
11 :: distributed under the License is distributed on an "AS IS" BASIS,
12 :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 :: See the License for the specific language governing permissions and
14 :: limitations under the License.
15 :: 
16 :: SPDX-License-Identifier: Apache-2.0
17 :: ============LICENSE_END=========================================================
18
19 ::
20 :: Script to run APEX Applications, call with '-h' for help
21 :: - adding a new app means to add a command to APEX_APP_MAP and a description to APEX_APP_DESCR_MAP using same/unique key
22 ::
23 :: @package    org.onap.policy.apex
24 :: @author     Sven van der Meer <sven.van.der.meer@ericsson.com>
25 :: @version    v2.0.0
26
27 ::
28 :: DO NOT CHANGE CODE BELOW, unless you know what you are doing
29 ::
30
31 @echo off
32 setlocal enableDelayedExpansion
33
34
35 if defined APEX_HOME (
36     if exist "%APEX_HOME%\" (
37         set _dummy=dir
38     ) else (
39         echo[
40         echo Apex directory 'APEX_HOME' not a directory
41         echo Please set environment for 'APEX_HOME'
42         echo[
43         exit /b
44     )
45 ) else (
46     echo[
47     echo Apex directory 'APEX_HOME' not set
48     echo Please set environment for 'APEX_HOME'
49     echo[
50     exit /b
51 )
52
53 :: Environment variables for HTTPS
54 set KEYSTORE=%APEX_HOME%/etc/ssl/policy-keystore"
55 set KEYSTORE_PASSWD="Pol1cy_0nap"
56 set TRUSTSTORE=%APEX_HOME%/etc/ssl/policy-truststore"
57 set TRUSTSTORE_PASSWD="Pol1cy_0nap"
58
59 :: HTTPS parameters
60 set HTTPS_PARAMETERS=-Djavax.net.ssl.keyStore=%KEYSTORE% -Djavax.net.ssl.keyStorePassword=%KEYSTORE_PASSWD% -Djavax.net.ssl.trustStore=%TRUSTSTORE% -Djavax.net.ssl.trustStorePassword=%TRUSTSTORE_PASSWD%
61
62 :: script name for output
63 set MOD_SCRIPT_NAME=apexApps
64
65 :: config for CP apps
66 SET _CONFIG=%HTTPS_PARAMETERS% -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -Dhazelcast.config=%APEX_HOME%\etc\hazelcast.xml -Dhazelcast.mancenter.enabled=false
67
68 :: Maven/APEX version
69 set /p _VERSION=<%APEX_HOME%\etc\app-version.txt
70
71
72 :: CP separator
73 set cpsep=;
74
75
76 :: CP for CP apps
77 set CLASSPATH=%APEX_HOME%\etc%cpsep%%APEX_HOME%\etc\hazelcast%cpsep%%APEX_HOME%\etc\infinispan%cpsep%%APEX_HOME%\lib\*
78
79
80 :: array of applications with name=command
81 :: declare -A APEX_APP_MAP
82 set APEX_APP_MAP[ws-console]=java -jar %APEX_HOME%\lib\applications\simple-wsclient-%_VERSION%-jar-with-dependencies.jar -c
83 set APEX_APP_MAP[ws-echo]=java -jar %APEX_HOME%\lib\applications\simple-wsclient-%_VERSION%-jar-with-dependencies.jar
84 set APEX_APP_MAP[tpl-event-json]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.tools.model.generator.model2event.Model2EventMain
85 set APEX_APP_MAP[model-2-cli]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.tools.model.generator.model2cli.Model2CliMain
86 set APEX_APP_MAP[rest-editor]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-editor-%_VERSION%-editor.jar
87 set APEX_APP_MAP[cli-editor]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.auth.clieditor.ApexCommandLineEditorMain
88 set APEX_APP_MAP[engine]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.service.engine.main.ApexMain
89 set APEX_APP_MAP[eng-deployment]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-deployment-%_VERSION%-deployment.jar
90 set APEX_APP_MAP[eng-monitoring]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-monitoring-%_VERSION%-monitoring.jar
91 set APEX_APP_MAP[full-client]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -jar %APEX_HOME%\lib\applications\client-full-%_VERSION%-full.jar
92 set APEX_APP_MAP[event-generator]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.EventGenerator
93 set APEX_APP_MAP[onappf]=java -Dlogback.configurationFile=%APEX_HOME%\etc\logback.xml -cp %CLASSPATH% %_CONFIG% org.onap.policy.apex.services.onappf.ApexStarterMain
94
95 :: array of applications with name=description
96 :: declare -A APEX_APP_DESCR_MAP
97 set APEX_APP_DESCR_MAP[ws-console]=a simple console sending events to APEX, connect to APEX consumer port
98 set APEX_APP_DESCR_MAP[ws-echo]=a simple echo client printing events received from APEX, connect to APEX producer port
99 set APEX_APP_DESCR_MAP[tpl-event-json]=provides JSON templates for events generated from a policy model
100 set APEX_APP_DESCR_MAP[model-2-cli]=generates CLI Editor Commands from a policy model
101 set APEX_APP_DESCR_MAP[rest-editor]=starts the APEX REST Editor inside a simple webserver
102 set APEX_APP_DESCR_MAP[cli-editor]=runs the APEX CLI Editor
103 set APEX_APP_DESCR_MAP[engine]=starts the APEX engine
104 set APEX_APP_DESCR_MAP[eng-deployment]=starts the APEX deployment client in a simple webserver
105 set APEX_APP_DESCR_MAP[eng-monitoring]=starts the APEX engine monitoring client in a simple webserver
106 set APEX_APP_DESCR_MAP[full-client]=starts the full APEX client (rest editor, deployment, monitoring) in a simple webserver
107 set APEX_APP_DESCR_MAP["event-generator"]=starts the event generator in a simple webserver for performance testing
108 set APEX_APP_DESCR_MAP[onappf]=starts the ApexStarter which handles the Apex Engine based on instructions from PAP
109
110 :: no command line means help, -h means help
111 if "%1" == "" goto Help
112 if "%1" == "-h" goto Help
113
114 :: -l means list
115 if "%1" == "-l" goto ListApps
116
117 :: -d means describe
118 if "%1" == "-d" goto DescribeApp
119
120
121 ::
122 :: ok, we need to look for an application, should be in %1
123 ::
124 set _APP=%1
125
126 set _CMD=!APEX_APP_MAP[%_APP%]!
127 if "!_CMD!" == "" (
128     echo %MOD_SCRIPT_NAME%: : application '%_APP%' not supported
129     echo[
130     exit /b
131 )
132
133 for /f "tokens=1,* delims= " %%a in ("%*") do set ACTUAL_CLI=%%b
134 set _CMD_RUN=%_CMD% %ACTUAL_CLI%
135 :: echo %MOD_SCRIPT_NAME%: running application %_APP%' with command '%_CMD_RUN%'
136 %_CMD_RUN%
137 exit /b
138
139
140 ::
141 :: Help screen and exit condition (i.e. too few arguments)
142 ::
143 :Help
144 echo[
145 echo %MOD_SCRIPT_NAME% - runs APEX applications
146 echo[
147 echo        Usage:  %MOD_SCRIPT_NAME% [options] ^| [^<application^> [^<application options^>]]
148 echo[
149 echo        Options
150 echo          -d ^<app^>    - describes an application
151 echo          -l          - lists all applications supported by this script
152 echo          -h          - this help screen
153 echo[
154 echo[
155 exit /b
156
157
158
159 ::
160 :: List applications
161 ::
162 :ListApps
163 echo[
164 echo %MOD_SCRIPT_NAME%: supported applications:
165 for /F "tokens=2,3 delims=[]=" %%a in ('set APEX_APP_MAP') do (
166     echo --^> %%a
167 )
168 echo[
169 exit /b
170
171
172 ::
173 :: Describe an application
174 ::
175 :DescribeApp
176 if "%2" == "" (
177     echo %MOD_SCRIPT_NAME%: : supported applications:
178     for /F "tokens=2,3 delims=[]=" %%a in ('set APEX_APP_MAP') do (
179         echo --^> %%a
180     )
181     echo[
182     exit /b
183 )
184 set _CMD=!APEX_APP_DESCR_MAP[%2%]!
185 if "%_CMD%" == "" (
186     echo %MOD_SCRIPT_NAME%: : unknown application '%2%'
187     echo[
188     exit /b
189 )
190 echo %MOD_SCRIPT_NAME%: : application '%2%'
191 echo --^> %_CMD%
192 echo[
193 exit /b