src/org/ohmage/jee/listener/KeycloakFileImport.java
@Override
	public void contextInitialized(ServletContextEvent event) {
		Properties properties = ConfigurationFileImport.getCustomProperties();
		String keycloakFileLocation = (String) properties.get(KEYCLOAK_CONFIG_PROPERTY_NAME);
		File keycloakFile;

		if (keycloakFileLocation != null) {
			keycloakFile = new File(keycloakFileLocation);

			Map<String,String> map;
			ObjectMapper mapper = new ObjectMapper();

			try {
				TypeReference<Map<String, String>> ref = new TypeReference<Map<String, String>>() { };
				map = mapper.readValue(keycloakFile, ref);
				KeycloakCache.setCache(map);

				LOGGER
				.log(Level.INFO, 
						"The keycloak.json file was loaded from: " +
								keycloakFile.getAbsolutePath());

			}
			// Mapper failed to parse the keycloak.json file
			catch (JsonParseException e){
				LOGGER.log(Level.WARNING, 
						"Error while parsing keycloak.json file. "
								+ "Keycloak will be disabled.",
								e);
			}
			// One or more arguments were passed as null instead of intended.
			catch (IllegalArgumentException e){
				LOGGER.log(Level.WARNING, 
						"Bad arguments while attempting to set up keycloak. "
								+ "Keycloak will be disabled.",
								e);
			}
			// The keycloak.json file was not found.
			catch(FileNotFoundException e) {
				LOGGER
				.log(
						Level.WARNING, 
						"The keycloak.json file was not found at location: " +
								keycloakFile.getAbsolutePath(),
								e);
			}
			// There was an error reading the keycloak.json file.
			catch(IOException e) {
				LOGGER
				.log(
						Level.WARNING, 
						"There was an error reading the keycloak.json file: " +
								keycloakFile.getAbsolutePath(),
								e);
			}
		}
		else {
			LOGGER
			.log(Level.INFO, 
					"No keycloak.json file passed. "
							+ "This functionality will be disabled.");		
		}
	}
/**
	 * Find the keycloak.json file and attempt set up the cache which holds keycloak properties.
	 */
Find the keycloak.json file and attempt set up the cache which holds keycloak properties.
Find the keycloak . json file and attempt set up the cache which holds keycloak properties .
@Override
	public void contextInitialized(ServletContextEvent event) {
		Properties properties = ConfigurationFileImport.getCustomProperties();
		String keycloakFileLocation = (String) properties.get(KEYCLOAK_CONFIG_PROPERTY_NAME);
		File keycloakFile;
		if (keycloakFileLocation != null) {
			keycloakFile = new File(keycloakFileLocation);
			Map<String,String> map;
			ObjectMapper mapper = new ObjectMapper();
			try {
				TypeReference<Map<String, String>> ref = new TypeReference<Map<String, String>>() { };
				map = mapper.readValue(keycloakFile, ref);
				KeycloakCache.setCache(map);
				LOGGER
				.log(Level.INFO, 
						"The keycloak.json file was loaded from: " +
								keycloakFile.getAbsolutePath());
			}
			catch (JsonParseException e){
				LOGGER.log(Level.WARNING, 
						"Error while parsing keycloak.json file. "
								+ "Keycloak will be disabled.",
								e);
			}
			catch (IllegalArgumentException e){
				LOGGER.log(Level.WARNING, 
						"Bad arguments while attempting to set up keycloak. "
								+ "Keycloak will be disabled.",
								e);
			}
			catch(FileNotFoundException e) {
				LOGGER
				.log(
						Level.WARNING, 
						"The keycloak.json file was not found at location: " +
								keycloakFile.getAbsolutePath(),
								e);
			}
			catch(IOException e) {
				LOGGER
				.log(
						Level.WARNING, 
						"There was an error reading the keycloak.json file: " +
								keycloakFile.getAbsolutePath(),
								e);
			}
		}
		else {
			LOGGER
			.log(Level.INFO, 
					"No keycloak.json file passed. "
							+ "This functionality will be disabled.");		
		}
	}
@ Override public void contextInitialized ( ServletContextEvent event ) { Properties properties = ConfigurationFileImport . getCustomProperties ( ) ; String keycloakFileLocation = ( String ) properties . get ( KEYCLOAK_CONFIG_PROPERTY_NAME ) ; File keycloakFile ; if ( keycloakFileLocation != null ) { keycloakFile = new File ( keycloakFileLocation ) ; Map < String , String > map ; ObjectMapper mapper = new ObjectMapper ( ) ; try { TypeReference < Map < String , String > > ref = new TypeReference < Map < String , String > > ( ) { } ; map = mapper . readValue ( keycloakFile , ref ) ; KeycloakCache . setCache ( map ) ; LOGGER . log ( Level . INFO , "The keycloak.json file was loaded from: " + keycloakFile . getAbsolutePath ( ) ) ; } catch ( JsonParseException e ) { LOGGER . log ( Level . WARNING , "Error while parsing keycloak.json file. " + "Keycloak will be disabled." , e ) ; } catch ( IllegalArgumentException e ) { LOGGER . log ( Level . WARNING , "Bad arguments while attempting to set up keycloak. " + "Keycloak will be disabled." , e ) ; } catch ( FileNotFoundException e ) { LOGGER . log ( Level . WARNING , "The keycloak.json file was not found at location: " + keycloakFile . getAbsolutePath ( ) , e ) ; } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "There was an error reading the keycloak.json file: " + keycloakFile . getAbsolutePath ( ) , e ) ; } } else { LOGGER . log ( Level . INFO , "No keycloak.json file passed. " + "This functionality will be disabled." ) ; } }
Find the keycloak.json file and attempt set up the cache which holds keycloak properties.
Find the keycloak . json file and attempt set up the cache which holds keycloak properties .
// Mapper failed to parse the keycloak.json file // One or more arguments were passed as null instead of intended. // The keycloak.json file was not found. // There was an error reading the keycloak.json file.