Skip to content

Commit 61f1156

Browse files
author
Gábor Koródi
authored
Merge pull request #19 from hms-dbmi/DI-994_whitelist_functionality
DI-994 add final to the naming utility class
2 parents 6002012 + e43b462 commit 61f1156

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/IRCTApplication.java

+15-4
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,15 @@ public boolean doesJoinExists(String name) {
389389

390390
/**
391391
* Loads the white lists into application
392+
*
393+
* <p>Instead of using @javax.annotation.Resource to auto read the resource from JNDI,
394+
* which is kind of mandatory (throw a <code>NamingException</code> never be handled and will stop the load progress),
395+
* here we read and handle the exception to not stop the progress, which kind of allowing optionally configure.
396+
*
397+
* <p>For exception handling: besides disabling the functionality - setting the field in configuration xml file
398+
* to false or the location field is not in the list,
399+
* all other exceptions will end up not making any changes to the whitelist map, which means will never break
400+
* the load progress.
392401
* @author yuzhang
393402
*/
394403
private void loadWhiteLists() {
@@ -405,7 +414,9 @@ private void loadWhiteLists() {
405414
whitelistEnabled = false;
406415
return;
407416
} else {
408-
whitelist = new HashMap<>();
417+
// to be able to support change the configuration white list Json file at runtime
418+
if (whitelist == null)
419+
whitelist = new HashMap<>();
409420
whitelistEnabled = true;
410421
}
411422

@@ -428,7 +439,7 @@ private void loadWhiteLists() {
428439
log.info("Added one email from whitelist: " + name
429440
+ " with resources: " + resources.toString());
430441
} catch (ClassCastException | NullPointerException npe) {
431-
log.log(Level.SEVERE, "The format of each object in whitelist array is not right. Please take a look into the sample whitelist json");
442+
log.log(Level.WARNING, "The format of each object in whitelist array is not right. Please take a look into the sample whitelist json");
432443
}
433444

434445
}
@@ -440,9 +451,9 @@ private void loadWhiteLists() {
440451
} catch (ClassCastException cce ) {
441452
// change this to Log4J would be great
442453
// I think another ticket is changing this to Log4j
443-
log.log(Level.SEVERE, "The root layer of whitelist should be an array");
454+
log.log(Level.WARNING, "The root layer of whitelist should be an array");
444455
} catch (JsonParsingException ex) {
445-
log.log(Level.INFO, "Input whitelist file is not well formatted");
456+
log.log(Level.WARNING, "Input whitelist file is not well formatted");
446457
}
447458
}
448459

IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/util/Utilities.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
public class Utilities {
99

10-
public static class Naming {
10+
public final static class Naming {
1111

12-
public static class Whitelist{
12+
public final static class Whitelist{
1313
public static String JSON_NAME = "userid";
1414
public static String JSON_RESOURCES = "resources";
1515
}

0 commit comments

Comments
 (0)