+ @Override
+ public void run(ExtsysAppConfiguration configuration, Environment environment) {
+ LOGGER.info("Start to initialize esr.");
+ MsbConfig.setMsbServerAddr(configuration.getMsbServerAddr());
+ MsbConfig.setMsbDiscoveryIp(configuration.getMsbDiscoveryIp());
+ MsbConfig.setMsbDiscoveryPort(configuration.getMsbDiscoveryPort());
+ environment.jersey().register(new EmsManager());
+ environment.jersey().register(new ThirdpartySdncManager());
+ environment.jersey().register(new VimManager());
+ environment.jersey().register(new VnfmManager());
+ environment.jersey().register(new ServiceTest());
+ initSwaggerConfig(environment, configuration);
+ if ("false".equals(configuration.getRegistByHand())) {
+ String MSB_IP = configuration.getMsbDiscoveryIp();
+ Integer MSB_Port = Integer.valueOf(configuration.getMsbDiscoveryPort());
+ MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port);
+ MsbHelper helper = new MsbHelper(msbClient);
+ try {
+ helper.registerMsb();
+ LOGGER.info("Register esr-server to msb by java-sdk finished");
+ } catch (Exception e) {
+ LOGGER.error("Register esr-server to msb by java-sdk failed", e);
+ }
+ }
+ LOGGER.info("Initialize extsys finished.");
+ }
+
+ /**
+ * initialize swagger configuration.
+ *
+ * @param environment environment information
+ * @param configuration catalogue configuration
+ */
+ private void initSwaggerConfig(Environment environment, ExtsysAppConfiguration configuration) {
+ environment.jersey().register(new ApiListingResource());
+ environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ BeanConfig config = new BeanConfig();
+ config.setTitle("ONAP ESR Service rest API");
+ config.setVersion("1.0.0");
+ config.setResourcePackage("org.onap.aai.esr.resource");
+ // set rest api basepath in swagger
+ SimpleServerFactory simpleServerFactory =
+ (SimpleServerFactory) configuration.getServerFactory();
+ String basePath = simpleServerFactory.getApplicationContextPath();
+ String rootPath = simpleServerFactory.getJerseyRootPath().get();
+ rootPath = rootPath.substring(0, rootPath.indexOf("/*"));
+ basePath =
+ basePath.equals("/") ? rootPath : (new StringBuilder()).append(basePath)
+ .append(rootPath).toString();
+ LOGGER.info("getApplicationContextPath: " + basePath);
+ config.setBasePath(basePath);
+ config.setScan(true);
+ }
+