|
9 | 9 | import com.solacecoe.connectors.spark.streaming.solace.LVQEventListener; |
10 | 10 | import com.solacecoe.connectors.spark.streaming.solace.SolaceBroker; |
11 | 11 | import com.solacecoe.connectors.spark.streaming.solace.exceptions.SolaceInvalidPropertyException; |
12 | | -import com.solacesystems.jcsmp.JCSMPProperties; |
| 12 | +import com.solacecoe.connectors.spark.streaming.solace.utils.SolaceUtils; |
13 | 13 | import org.apache.logging.log4j.LogManager; |
14 | 14 | import org.apache.logging.log4j.Logger; |
15 | 15 | import org.apache.spark.SparkEnv; |
@@ -48,48 +48,7 @@ public SolaceMicroBatch(Map<String, String> properties) { |
48 | 48 | log.info("SolaceSparkConnector - Initializing Solace Spark Connector"); |
49 | 49 | // Initialize classes required for Solace connectivity |
50 | 50 |
|
51 | | - // User configuration validation |
52 | | - if(!properties.containsKey(SolaceSparkStreamingProperties.HOST) || properties.get(SolaceSparkStreamingProperties.HOST) == null || properties.get(SolaceSparkStreamingProperties.HOST).isEmpty()) { |
53 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide Solace Host name in configuration options"); |
54 | | - } |
55 | | - if(!properties.containsKey(SolaceSparkStreamingProperties.VPN) || properties.get(SolaceSparkStreamingProperties.VPN) == null || properties.get(SolaceSparkStreamingProperties.VPN).isEmpty()) { |
56 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide Solace VPN name in configuration options"); |
57 | | - } |
58 | | - |
59 | | - if(properties.containsKey(SolaceSparkStreamingProperties.SOLACE_API_PROPERTIES_PREFIX+ JCSMPProperties.AUTHENTICATION_SCHEME) && |
60 | | - properties.get(SolaceSparkStreamingProperties.SOLACE_API_PROPERTIES_PREFIX+ JCSMPProperties.AUTHENTICATION_SCHEME).equals(JCSMPProperties.AUTHENTICATION_SCHEME_OAUTH2)) { |
61 | | - if(!properties.containsKey(SolaceSparkStreamingProperties.OAUTH_CLIENT_ACCESSTOKEN)) { |
62 | | - if(!properties.containsKey(SolaceSparkStreamingProperties.OAUTH_CLIENT_AUTHSERVER_URL) || properties.get(SolaceSparkStreamingProperties.OAUTH_CLIENT_AUTHSERVER_URL) == null || properties.get(SolaceSparkStreamingProperties.OAUTH_CLIENT_AUTHSERVER_URL).isEmpty()) { |
63 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide OAuth Client Authentication Server URL"); |
64 | | - } |
65 | | - |
66 | | - if(!properties.containsKey(SolaceSparkStreamingProperties.OAUTH_CLIENT_CLIENT_ID) || properties.get(SolaceSparkStreamingProperties.OAUTH_CLIENT_CLIENT_ID) == null || properties.get(SolaceSparkStreamingProperties.OAUTH_CLIENT_CLIENT_ID).isEmpty()) { |
67 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide OAuth Client ID"); |
68 | | - } |
69 | | - |
70 | | - if(!properties.containsKey(SolaceSparkStreamingProperties.OAUTH_CLIENT_CREDENTIALS_CLIENTSECRET) || properties.get(SolaceSparkStreamingProperties.OAUTH_CLIENT_CREDENTIALS_CLIENTSECRET) == null || properties.get(SolaceSparkStreamingProperties.OAUTH_CLIENT_CREDENTIALS_CLIENTSECRET).isEmpty()) { |
71 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide OAuth Client Credentials Secret"); |
72 | | - } |
73 | | - |
74 | | - String clientCertificate = properties.getOrDefault(SolaceSparkStreamingProperties.OAUTH_CLIENT_AUTHSERVER_CLIENT_CERTIFICATE, null); |
75 | | - if(clientCertificate != null) { |
76 | | - String trustStoreFilePassword = properties.getOrDefault(SolaceSparkStreamingProperties.OAUTH_CLIENT_AUTHSERVER_TRUSTSTORE_PASSWORD, null); |
77 | | - if (trustStoreFilePassword == null || trustStoreFilePassword.isEmpty()) { |
78 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide OAuth Client TrustStore Password. If TrustStore file path is not configured, please provide password for default java truststore"); |
79 | | - } |
80 | | - } |
81 | | - } else if(properties.getOrDefault(SolaceSparkStreamingProperties.OAUTH_CLIENT_ACCESSTOKEN, null) == null || properties.getOrDefault(SolaceSparkStreamingProperties.OAUTH_CLIENT_ACCESSTOKEN, null).isEmpty()) { |
82 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide valid access token input"); |
83 | | - } |
84 | | - } else { |
85 | | - if (!properties.containsKey(SolaceSparkStreamingProperties.USERNAME) || properties.get(SolaceSparkStreamingProperties.USERNAME) == null || properties.get(SolaceSparkStreamingProperties.USERNAME).isEmpty()) { |
86 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide Solace Username in configuration options"); |
87 | | - } |
88 | | - |
89 | | - if (!properties.containsKey(SolaceSparkStreamingProperties.PASSWORD) || properties.get(SolaceSparkStreamingProperties.PASSWORD) == null || properties.get(SolaceSparkStreamingProperties.PASSWORD).isEmpty()) { |
90 | | - throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide Solace Password in configuration options"); |
91 | | - } |
92 | | - } |
| 51 | + SolaceUtils.validateCommonProperties(properties); |
93 | 52 |
|
94 | 53 | if(!properties.containsKey(SolaceSparkStreamingProperties.QUEUE) || properties.get(SolaceSparkStreamingProperties.QUEUE) == null || properties.get(SolaceSparkStreamingProperties.QUEUE).isEmpty()) { |
95 | 54 | throw new SolaceInvalidPropertyException("SolaceSparkConnector - Please provide Solace Queue in configuration options"); |
|
0 commit comments