@@ -92,7 +92,7 @@ public enum LicenseResolutionSource {
9292 protected Set <String > requiredFeatures = new HashSet <>();
9393 protected int minWorkerCount = 0 ;
9494 protected int maxWorkerCount = 0 ;
95- protected String targetShortName = null ;
95+ protected List < String > targetShortNames = null ;
9696 protected Function <Stream <AvailableLicence >, Optional <AvailableLicence >> finalDecider ;
9797
9898 protected NuixLicenseResolver () {
@@ -225,6 +225,25 @@ public NuixLicenseResolver withMaxWorkerCount(int maxWorkerCount) {
225225 return this ;
226226 }
227227
228+ /***
229+ * Specifies one or more license shortnames that desired license must have to be acceptable.
230+ * @param shortNames One or more Nuix license short names (enterprise-workstation, enterprise-reviewer, etc).
231+ * @return This license resolver for chained method calls.
232+ */
233+ public NuixLicenseResolver withLicenseShortNameMatching (String ... shortNames ) {
234+ if (shortNames .length < 1 ) {
235+ return this ;
236+ }
237+
238+ if (targetShortNames == null ) {
239+ targetShortNames = new ArrayList <>();
240+ }
241+
242+ targetShortNames .addAll (Arrays .asList (shortNames ));
243+
244+ return this ;
245+ }
246+
228247 /***
229248 * Allows you to provide a function which makes the final decision as to which available license to obtain.
230249 * Supplied function will be provided Stream of AvailableLicenses after this license resolver has applied any
@@ -315,7 +334,7 @@ public NuixLicenseResolver withTrustAllCertificates() {
315334 public boolean resolveLicense (@ NonNull Engine engine ) throws Exception {
316335 Map <String , Object > licenseOptions = Collections .emptyMap ();
317336
318- log .info ("License Source: " + licenseSource );
337+ log .info ("License Source: " + licenseSource );
319338
320339 switch (licenseSource ) {
321340 case Cloud :
@@ -355,7 +374,7 @@ public boolean resolveLicense(@NonNull Engine engine) throws Exception {
355374
356375 log .info ("Applying filtering to available licenses..." );
357376 Stream <AvailableLicence > filteredLicensesStream = availableLicensesStream .filter ((availableLicense -> {
358- log .info ("Inspecting license: " + NuixLicenseFeaturesLogger .summarizeLicense (availableLicense ));
377+ log .info ("Inspecting license: " + NuixLicenseFeaturesLogger .summarizeLicense (availableLicense ));
359378
360379 // It is possible to get a Licence specifically for running an NMS instance and not an Engine instance
361380 // which we can ignore since it cannot license an Engine instance for us.
@@ -386,9 +405,10 @@ public boolean resolveLicense(@NonNull Engine engine) throws Exception {
386405
387406 // Verify short name
388407 String availableLicenseShortName = availableLicense .getShortName ().toLowerCase ();
389- if (targetShortName != null && !availableLicenseShortName .equalsIgnoreCase (targetShortName )) {
390- log .info (String .format ("License has shortname %s which does not match the target shortname %s" ,
391- availableLicenseShortName , targetShortName ));
408+ if (targetShortNames != null && !targetShortNames .isEmpty () &&
409+ targetShortNames .stream ().noneMatch (availableLicenseShortName ::equalsIgnoreCase )) {
410+ log .info (String .format ("License has shortname %s which does not match any of the target shortnames: %s" ,
411+ availableLicenseShortName , String .join (", " , targetShortNames )));
392412 return false ;
393413 }
394414
@@ -438,7 +458,7 @@ public String toString() {
438458 ", requiredFeatures=" + requiredFeatures +
439459 ", minWorkerCount=" + minWorkerCount +
440460 ", maxWorkerCount=" + maxWorkerCount +
441- ", targetShortName ='" + targetShortName + '\'' +
461+ ", targetShortNames ='" + targetShortNames + '\'' +
442462 '}' ;
443463 }
444464}
0 commit comments