/** Check whether device model is populated and offer to bootstrap system if not. */ protected void verifyDeviceModel() { try { IDeviceModelInitializer init = (IDeviceModelInitializer) SERVER_SPRING_CONTEXT.getBean(SiteWhereServerBeans.BEAN_DEVICE_MODEL_INITIALIZER); ISearchResults<ISite> sites = getDeviceManagement().listSites(new SearchCriteria(1, 1)); if (sites.getNumResults() == 0) { List<String> messages = new ArrayList<String>(); messages.add( "There are currently no sites defined in the system. You have the option of loading " + "a default dataset for previewing system functionality. Would you like to load the default " + "dataset?"); String message = StringMessageUtils.getBoilerPlate(messages, '*', 60); LOGGER.info("\n" + message + "\n"); System.out.println("Load default dataset? Yes/No (Default is Yes)"); String response = readLine(); if ((response == null) && (init.isInitializeIfNoConsole())) { response = "Y"; } else if ((response == null) && (!init.isInitializeIfNoConsole())) { response = "N"; } if ((response.length() == 0) || (response.toLowerCase().startsWith("y"))) { init.initialize(getDeviceManagement()); } } } catch (NoSuchBeanDefinitionException e) { LOGGER.info("No device model initializer found in Spring bean configuration. Skipping."); return; } catch (SiteWhereException e) { LOGGER.warn("Unable to read from device model.", e); } }