package configuration; import com.senzing.sdk.*; import com.senzing.sdk.core.SzCoreEnvironment; /** * Provides a simple example of adding records to the Senzing repository. */ public class InitDefaultConfig { public static void main(String[] args) { // get the senzing repository settings String settings = System.getenv("SENZING_ENGINE_CONFIGURATION_JSON"); if (settings == null) { System.err.println("Unable to get settings."); throw new IllegalArgumentException("Unable to get settings"); } // create a descriptive instance name (can be anything) String instanceName = InitDefaultConfig.class.getSimpleName(); // initialize the Senzing environment SzEnvironment env = SzCoreEnvironment.newBuilder() .settings(settings) .instanceName(instanceName) .verboseLogging(false) .build(); try { // get the config and config manager from the environment SzConfigManager configMgr = env.getConfigManager(); // prepare a config to be modified SzConfig config = configMgr.createConfig(); String configDefinition = config.export(); // register the modified config in the repository as the default configMgr.setDefaultConfig(configDefinition); } catch (SzException e) { // handle any exception that may have occurred System.err.println("Senzing Error Message : " + e.getMessage()); System.err.println("Senzing Error Code : " + e.getErrorCode()); e.printStackTrace(); throw new RuntimeException(e); } catch (Exception e) { e.printStackTrace(); if (e instanceof RuntimeException) { throw ((RuntimeException) e); } throw new RuntimeException(e); } finally { // IMPORTANT: make sure to destroy the environment env.destroy(); } } }