/** * Validates a connection property value. * <p> * Ensures that the connection property value is not {@code null}, has a length * greater than zero and matches the validation regular expression. * * @param propertyValue the connection property value * @throws IllegalArgumentException if the given {@code propertyValue} is {@code null} or zero length or * does not match the validation regular expression */ public void validateValue(String propertyValue) { validateValue(propertyValue, ""); }
/** * Loads the {@code ForceConnectionProperty} enum value from a connection * property name. * * @param propertyName A connection property name * @return The {@code ForceConnectionProperty} enum value matching the given * propertyName or {@code null} if no such value exists */ public static ForceConnectionProperty fromPropertyName(String propertyName) { if (propertyName == null) return null; for (ForceConnectionProperty connProp : values()) { if (connProp.getPropertyName().equals(propertyName.toLowerCase())) return connProp; } return null; } }
ForceConnectionProperty.ENDPOINT.validateValue(endpoint, "Illegal connection url (" + connectionUrl + ")."); connectorPropMap.put(ForceConnectionProperty.ENDPOINT, endpoint); ForceConnectionProperty connProp = ForceConnectionProperty.fromPropertyName(parsedUrlProperty[0]);
static Map<ForceConnectionProperty, String> loadConnectorPropsFromFile(URL fileUrl) throws IOException { if (fileUrl == null) throw new IllegalArgumentException("Connector property file cannot be null."); Properties connectorProps = new Properties(); InputStream is = null; try { is = fileUrl.openStream(); connectorProps.load(is); } finally { if (is != null) is.close(); } if (connectorProps.containsKey("url")) { return loadConnectorPropsFromUrl(connectorProps.getProperty("url")); } Map<ForceConnectionProperty, String> connectorPropMap = new HashMap<ForceConnectionProperty, String>(connectorProps.size()); for (String propName : connectorProps.stringPropertyNames()) { ForceConnectionProperty connProp = ForceConnectionProperty.fromPropertyName(propName); if (connProp != null) { connectorPropMap.put(connProp, connectorProps.getProperty(propName)); } } return connectorPropMap; }
ForceConnectionProperty.ENDPOINT.validateValue(endpoint, "Illegal connection url (" + connectionUrl + ")."); connectorPropMap.put(ForceConnectionProperty.ENDPOINT, endpoint); ForceConnectionProperty connProp = ForceConnectionProperty.fromPropertyName(parsedUrlProperty[0]);
static Map<ForceConnectionProperty, String> loadConnectorPropsFromFile(URL fileUrl) throws IOException { if (fileUrl == null) throw new IllegalArgumentException("Connector property file cannot be null."); Properties connectorProps = new Properties(); InputStream is = null; try { is = fileUrl.openStream(); connectorProps.load(is); } finally { if (is != null) is.close(); } if (connectorProps.containsKey("url")) { return loadConnectorPropsFromUrl(connectorProps.getProperty("url")); } Map<ForceConnectionProperty, String> connectorPropMap = new HashMap<ForceConnectionProperty, String>(connectorProps.size()); for (String propName : connectorProps.stringPropertyNames()) { ForceConnectionProperty connProp = ForceConnectionProperty.fromPropertyName(propName); if (connProp != null) { connectorPropMap.put(connProp, connectorProps.getProperty(propName)); } } return connectorPropMap; }
/** * Validates a connection property value. * <p> * Ensures that the connection property value is not {@code null}, has a length * greater than zero and matches the validation regular expression. * * @param propertyValue the connection property value * @throws IllegalArgumentException if the given {@code propertyValue} is {@code null} or zero length or * does not match the validation regular expression */ public void validateValue(String propertyValue) { validateValue(propertyValue, ""); }
/** * Loads the {@code ForceConnectionProperty} enum value from a connection * property name. * * @param propertyName A connection property name * @return The {@code ForceConnectionProperty} enum value matching the given * propertyName or {@code null} if no such value exists */ public static ForceConnectionProperty fromPropertyName(String propertyName) { if (propertyName == null) return null; for (ForceConnectionProperty connProp : values()) { if (connProp.getPropertyName().equals(propertyName.toLowerCase())) return connProp; } return null; } }
/** * Ensures that the data represents a valid OAuth connection. */ public void validate() { ForceConnectionProperty.ENDPOINT.validateValue(getEndpoint()); ForceConnectionProperty.OAUTH_KEY.validateValue(getOauthKey()); ForceConnectionProperty.OAUTH_SECRET.validateValue(getOauthSecret()); } }
/** * Ensures that the data represents a valid OAuth connection. */ public void validate() { ForceConnectionProperty.ENDPOINT.validateValue(getEndpoint()); ForceConnectionProperty.OAUTH_KEY.validateValue(getOauthKey()); ForceConnectionProperty.OAUTH_SECRET.validateValue(getOauthSecret()); } }
private void setPropsFromMap(Map<ForceConnectionProperty, String> propMap, String propSource) { String errorMessage = "Could not load valid ForceOAuthConnectionInfo properties from " + propSource + "."; String endpointValue = propMap.get(ForceConnectionProperty.ENDPOINT); ForceConnectionProperty.ENDPOINT.validateValue(endpointValue, errorMessage); setEndpoint(endpointValue); String oauthKeyValue = propMap.get(ForceConnectionProperty.OAUTH_KEY); ForceConnectionProperty.OAUTH_KEY.validateValue(oauthKeyValue, errorMessage); setOauthKey(oauthKeyValue); String oauthSecretValue = propMap.get(ForceConnectionProperty.OAUTH_SECRET); ForceConnectionProperty.OAUTH_SECRET.validateValue(oauthSecretValue, errorMessage); setOauthSecret(oauthSecretValue); }
private void setPropsFromMap(Map<ForceConnectionProperty, String> propMap, String propSource) { String errorMessage = "Could not load valid ForceOAuthConnectionInfo properties from " + propSource + "."; String endpointValue = propMap.get(ForceConnectionProperty.ENDPOINT); ForceConnectionProperty.ENDPOINT.validateValue(endpointValue, errorMessage); setEndpoint(endpointValue); String oauthKeyValue = propMap.get(ForceConnectionProperty.OAUTH_KEY); ForceConnectionProperty.OAUTH_KEY.validateValue(oauthKeyValue, errorMessage); setOauthKey(oauthKeyValue); String oauthSecretValue = propMap.get(ForceConnectionProperty.OAUTH_SECRET); ForceConnectionProperty.OAUTH_SECRET.validateValue(oauthSecretValue, errorMessage); setOauthSecret(oauthSecretValue); }
private void setPropsFromMap(Map<ForceConnectionProperty, String> propMap, String propSource) { String errorMessage = "Could not load valid ForceConnectorConfig properties from " + propSource + "."; String endpointValue = propMap.get(ForceConnectionProperty.ENDPOINT); ForceConnectionProperty.ENDPOINT.validateValue(endpointValue, errorMessage); setAuthEndpoint(endpointValue); String userValue = propMap.get(ForceConnectionProperty.USER); ForceConnectionProperty.USER.validateValue(userValue, errorMessage); setUsername(userValue); String passwordValue = propMap.get(ForceConnectionProperty.PASSWORD); ForceConnectionProperty.PASSWORD.validateValue(passwordValue, errorMessage); setPassword(passwordValue); String clientIdValue; if ((clientIdValue = propMap.get(ForceConnectionProperty.CLIENTID)) != null) { ForceConnectionProperty.CLIENTID.validateValue(clientIdValue, errorMessage); setClientId(clientIdValue); } String timeoutValue; if ((timeoutValue = propMap.get(ForceConnectionProperty.TIMEOUT)) != null) { ForceConnectionProperty.TIMEOUT.validateValue(timeoutValue, errorMessage); int timeout = Integer.valueOf(timeoutValue); if (timeout > 0) setReadTimeout(timeout); } }
private void setPropsFromMap(Map<ForceConnectionProperty, String> propMap, String propSource) { String errorMessage = "Could not load valid ForceConnectorConfig properties from " + propSource + "."; String endpointValue = propMap.get(ForceConnectionProperty.ENDPOINT); ForceConnectionProperty.ENDPOINT.validateValue(endpointValue, errorMessage); setAuthEndpoint(endpointValue); String userValue = propMap.get(ForceConnectionProperty.USER); ForceConnectionProperty.USER.validateValue(userValue, errorMessage); setUsername(userValue); String passwordValue = propMap.get(ForceConnectionProperty.PASSWORD); ForceConnectionProperty.PASSWORD.validateValue(passwordValue, errorMessage); setPassword(passwordValue); String clientIdValue; if ((clientIdValue = propMap.get(ForceConnectionProperty.CLIENTID)) != null) { ForceConnectionProperty.CLIENTID.validateValue(clientIdValue, errorMessage); setClientId(clientIdValue); } String timeoutValue; if ((timeoutValue = propMap.get(ForceConnectionProperty.TIMEOUT)) != null) { ForceConnectionProperty.TIMEOUT.validateValue(timeoutValue, errorMessage); int timeout = Integer.valueOf(timeoutValue); if (timeout > 0) setReadTimeout(timeout); } }