|
| 1 | +package com.nuix.innovation.enginewrapper; |
| 2 | + |
| 3 | +import nuix.Utilities; |
| 4 | +import org.joda.time.DateTime; |
| 5 | +import org.slf4j.Logger; |
| 6 | +import org.slf4j.LoggerFactory; |
| 7 | + |
| 8 | +import java.io.File; |
| 9 | +import java.io.IOException; |
| 10 | +import java.lang.management.ManagementFactory; |
| 11 | +import java.lang.management.RuntimeMXBean; |
| 12 | +import java.util.List; |
| 13 | +import java.util.Map; |
| 14 | + |
| 15 | +public class App { |
| 16 | + private static final Logger log = LoggerFactory.getLogger(App.class); |
| 17 | + private static boolean logEnvDetails = true; |
| 18 | + |
| 19 | + public static void main(String[] args) { |
| 20 | + logEnvDetails(); |
| 21 | + |
| 22 | + try (NuixEngine nuixEngine = constructNuixEngine()) { |
| 23 | + Utilities utilities = nuixEngine.getUtilities(); |
| 24 | + |
| 25 | + // This is where the magic happens. In this scope, Nuix should be licensed. |
| 26 | + // To run a test in the IDE, I recommend invoking from AppTest in the project tests. |
| 27 | + |
| 28 | + log.info("Nuix Engine Version: {}", nuixEngine.getNuixVersionString()); |
| 29 | + |
| 30 | + } catch (Exception exc) { |
| 31 | + log.error("Uncaught exception, exiting", exc); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + private static void logEnvDetails() { |
| 36 | + if (logEnvDetails) { |
| 37 | + System.out.println("JVM Arguments:"); |
| 38 | + RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean(); |
| 39 | + List<String> jvmArgs = bean.getInputArguments(); |
| 40 | + for (String arg : jvmArgs) { |
| 41 | + System.out.println(arg); |
| 42 | + } |
| 43 | + |
| 44 | + System.out.println("Environment Variables:"); |
| 45 | + for (Map.Entry<String, String> entry : System.getenv().entrySet()) { |
| 46 | + System.out.println(String.format("%s => %s", entry.getKey(), entry.getValue())); |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + /*** |
| 52 | + * Tests will generally call this method to construct the instance of NuixEngine they will use to perform |
| 53 | + * their given test. This allows you to customize it to your environment without having to alter all the tests. |
| 54 | + * @return A NuixEngine instance ready to use |
| 55 | + */ |
| 56 | + public static NuixEngine constructNuixEngine(String... additionalRequiredFeatures) throws IOException { |
| 57 | + List<String> features = List.of("CASE_CREATION"); |
| 58 | + if (additionalRequiredFeatures != null && additionalRequiredFeatures.length > 0) { |
| 59 | + features.addAll(List.of(additionalRequiredFeatures)); |
| 60 | + } |
| 61 | + |
| 62 | + NuixLicenseResolver cloud = NuixLicenseResolver.fromCloud() |
| 63 | + .withLicenseCredentialsResolvedFromEnvVars() |
| 64 | + .withMinWorkerCount(4) |
| 65 | + .withRequiredFeatures(features); |
| 66 | + |
| 67 | + NuixLicenseResolver dongle = NuixLicenseResolver.fromDongle() |
| 68 | + .withRequiredFeatures(features); |
| 69 | + |
| 70 | + NuixLicenseResolver nms = NuixLicenseResolver.fromServer("<NMS HOST OR IP>") |
| 71 | + .withMinWorkerCount(4) |
| 72 | + .withRequiredFeatures(features) |
| 73 | + .withRequiredFeatures(features); |
| 74 | + |
| 75 | + return NuixEngine.usingFirstAvailableLicense(cloud, nms, dongle) |
| 76 | + .setEngineDistributionDirectoryFromEnvVar() |
| 77 | + .setLogDirectory(new File("C:/NuixEngineLogs/", DateTime.now().toString("YYYY-MM-dd_HH-mm-ss")).getCanonicalFile()); |
| 78 | + } |
| 79 | +} |
0 commit comments