@Override public void checkConfiguration() throws ConfigurationException { for (String key : MANDATORY_CONFIGURATION_KEYS) { if (!configuration.stringIsSet(key)) { throw new ConfigurationException(key + " is mandatory and must not be empty."); } } }
public static void checkConfiguration(Configuration configuration) throws ConfigurationException { if (!configuration.stringIsSet(CK_INSTANCE_URL)) { throw new ConfigurationException(CK_INSTANCE_URL + " is mandatory and must not be empty."); } if (configuration.stringIsSet(CK_INSTANCE_URL) && !configuration.getString(CK_INSTANCE_URL).equals("null")) { try { final URI jiraUri = new URI(configuration.getString(CK_INSTANCE_URL)); if (!"http".equals(jiraUri.getScheme()) && !"https".equals(jiraUri.getScheme())) { throw new ConfigurationException(CK_INSTANCE_URL + " must be a valid HTTP or HTTPS URL."); } } catch (URISyntaxException e) { throw new ConfigurationException("Couldn't parse " + CK_INSTANCE_URL + " correctly.", e); } } if (!configuration.stringIsSet(CK_USERNAME)) { throw new ConfigurationException(CK_USERNAME + " is mandatory and must not be empty."); } if (!configuration.stringIsSet(CK_PASSWORD)) { throw new ConfigurationException(CK_PASSWORD + " is mandatory and must not be empty."); } if (!configuration.stringIsSet(CK_PROJECT_KEY)) { throw new ConfigurationException(CK_PROJECT_KEY + " is mandatory and must not be empty."); } if (!configuration.stringIsSet(CK_ISSUE_TYPE)) { throw new ConfigurationException(CK_ISSUE_TYPE + " is mandatory and must not be empty."); } if (configuration.stringIsSet(CK_GRAYLOG_URL) && !configuration.getString(CK_GRAYLOG_URL).equals("null")) { try { final URI graylogUri = new URI(configuration.getString(CK_GRAYLOG_URL)); if (!"http".equals(graylogUri.getScheme()) && !"https".equals(graylogUri.getScheme())) { throw new ConfigurationException(CK_GRAYLOG_URL + " must be a valid HTTP or HTTPS URL."); } } catch (URISyntaxException e) { throw new ConfigurationException("Couldn't parse " + CK_GRAYLOG_URL + " correctly.", e); } } }